How do I create a passback tag from a URL?

為{幸葍}努か 提交于 2019-12-05 02:08:43

Just an idea. What does it give if you try this ?

<SCRIPT language="JavaScript" type="text/javascript">

var script = document.createElement("script");
script.type = "text/javascript";  // This is for HTML 4.01 validation
script.src = "http://www.mydomain.com/passback.php";
document.getElementsByTagName("head")[0].appendChild(script);

</SCRIPT>

The script already provided is close to the one I always use for this:

var js = document.createElement("script");
js.type = "text/javascript";
js.src = "//www.mydomain.com/passback.php";
document.getElementsByTagName('head')[0].appendChild(js);

The only thing that is different is that the URL scheme is not specified therefore if you are running on an http server then the http url will be called and if you run on https then https will be called - mixing them would be reason that you scripts may not load.

With your script error I would suggest using Chrome and the developer tools - this would allow you to see exactly which line is giving you that error.

The following function loads another document into document body. The URL of the new document should be in the same domain which is http://www.mydomain.com/ in your case.

You need to save the following script as a .js file and put it where the ad should be placed.

function load(url) {
    var req = null;

    if (window.XMLHttpRequest) {
        req = new window.XMLHttpRequest();
    }
    else if (window.ActiveXObject) { //fallback
        try {
            req = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) { }
        }
    }

    if (req) {
        req.open("GET", url, false);
        req.send(null);
        return req.responseText;
    }
}

document.write(load("http://www.mydomain.com/passback.php"));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!