Adi*_*Adi 6 javascript ajax bookmarklet
我计划创建一个书签,用户将使用该书签在网站上分享内容(细菌网址和页面标题),例如mysite.com.所以这就是我现在所遵循的:
现在我的问题是......是否有可能的第三种方法,外部js文件可以通过mysite.com的ajax加载所有内容.或者由于bookmarklet将共享来自其他站点的内容,因此由于相同的源策略而无法工作.这可以工作的唯一方法是从iframe或弹出窗口中调用ajax?
使用弹出窗口与iframe方法有偏好还是缺点?
看一下 Instapaper.com 书签使用的方法:
javascript:function iprl5(){
var d=document,
z=d.createElement('scr'+'ipt'),
b=d.body,
l=d.location;
try{
if(!b)throw(0);
d.title='(Saving...)'+d.title;
z.setAttribute('src',l.protocol+'//www.instapaper.com/j/xxxxxxxx?u='+encodeURIComponent(l.href)+'&t='+(new Date().getTime()));
b.appendChild(z);
} catch(e) {
alert('Please wait until the page has loaded.');
}
}
iprl5();
void(0)
Run Code Online (Sandbox Code Playgroud)
事实上,他们使用 JSONP 并在页面上插入脚本标签。
归档时间: |
|
查看次数: |
1691 次 |
最近记录: |