Home  >  Article  >  Web Front-end  >  javascript simulate click ads_javascript skills

javascript simulate click ads_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:37:231167browse
1. Use a hidden iframe to load the advertising page.
Copy code The code is as follows:

Using the above code will cause the iframe to load the advertising page. If the page is too large, the speed will be very slow , You can use ajax to achieve refresh-free loading
Copy the code The code is as follows:

window.onload=function(){
...
var url="www.example.com/thiurl";//Advertising URL
xmlHttp.open("GET",url , true);//Use asynchronous transmission. This way the user will not feel any pause.
xmlHttp.send(null);
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readystate==4&&xmlHttp .status==200){
//Close the connection after the response is completed.
xmlHttp.close();
}
}
...
}

Here is just an idea, there may be a better way! (Note that it cannot be operated if it is cross-domain)
1.firefox:
var doc = document.getElementById('myiframe').contentWindow.document;
Then doc.getElementById
2. ie:
var doc = document.getElementById("myiframe").document;
Then doc.getElementById("iframeTitle");

Note that it will not work if it is cross-domain
The method of this code is to read the url to be simulated click based on className="touPiao" after the page is loaded. If it is #, it is the current page.
We can also set: I want to vote 1111
The program then starts to simulate clicking and reading according to the for loop, for(var el in els){ all urls.
Finally a url page will open, we can add an empty iframe,
For example:
And modify the link to: I want to vote 1111
In this way, after the page is loaded, simulate clicking on the page
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn