动态载入script,js跨站点访问数据

1.可以通过动态加载script标签来跨域载入变量。
跨域直接用ajax方式无法载入,但可以用scrit标签载入。
使用时可能有一些问题(没试成功),但可以先把值放到dom中传一下。

2.script标签有addEventListener onload事件,这上面处理变量载入成功以后事。

3.tor有时访问页面,需要加一个随机数强制刷新(未详测)

4.tor的ip更换很缓慢且不定,有时几十秒,有时几十分钟都没有更新ip。

5.tor主页显示的ip变得很快,实际上没有变。未知原因。

//动态载入Script标签(处理内存泄漏问题)
function OnScriptLoaded()
{
    
var status = document.title;
}

function LoadScript()
{
    
var script=document.getElementById('ScriptId');
    
if (script)
    {
        document.getElementsByTagName(
"head")[0].removeChild(script);
        script 
= null;
    }

    script
=document.createElement("script");
    script.type
="text/javascript";
    script.id
="ScriptId";
    script.addEventListener(
"load", OnScriptLoaded, false);
    script.src
="http://www.guoguoer.cn/abcd.php?p=u&rnd=" + Math.random();
    document.getElementsByTagName(
"head")[0].appendChild(script);
}

转载于:https://www.cnblogs.com/nonlyli/archive/2009/10/11/1581085.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值