1. Use hidden iframe to load ad pages.
Copy codeThe Code is as follows:
<! At the beginning, we used an invisible framework ID named: framelink -->
<Iframe id = "framelink" name = "framelink" frameBorder = "0" scrolling = "no" width = "0" height = "0"> </iframe>
<! -- Create a connection with the ID "myLink" -->
<A id = 'mylink' target = "framelink"> </a>
<! -- Write a js simulated click A connection with the ID "myLink" and set relevant properties -->
<SCRIPT language = JavaScript type = text/javascript>
<! --
Var GoUrl = "http://www.test.com"; // here is the site to simulate a click.
// If you want to support multiple site simulations, you can set GoUrl as an array. Traverse to perform the following actions.
Var myLink = document. getElementById ("myLink"); // The positioning element is "myLink"
MyLink. href = GoUrl; // set the href attribute of "myLink"
MyLink. click (); // simulate the click action
-->
</SCRIPT>
Using the above Code will cause iframe to load ad pages. If the page is too large, the speed will be very slow,You can use ajax to implement refreshing loads.
Copy codeThe Code is as follows:
Window. onload = function (){
...
Var url = "www.example.com/thiurl"; // the URL of the advertisement
XmlHttp. open ("GET", url, true); // use asynchronous transmission, so that the user does not feel any pause.
XmlHttp. send (null );
XmlHttp. onreadystatechange = function (){
If (xmlHttp. readystate = 4 & xmlHttp. status = 200 ){
// Close the connection after the response is complete.
XmlHttp. close ();
}
}
...
}
Here, we only provide one idea. It may be a better practice! (Note that cross-origin operations cannot be performed)
1. firefox:
Var doc = document.getelementbyid('myiframe'{.content}w.doc ument;
Then doc. getElementById
2. ie:
Var doc = document. getElementById ("myiframe" ).doc ument;
Then doc. getElementById ("iframeTitle ");
Note that cross-origin operations cannot be performed.
This code is used to read the url of the simulated click Based on className = "touPiao" after the page is loaded, for example, #, that is, the current page,
You can also set <a href = "www.javaeye.com" onclick = "showModify (this)" class = "touPiao"> I want to vote for 1111 </a>
The program then simulates all the URLs read by clicking for (var el in els) {according to the for loop.
Finally, a url page will be opened. We can add an empty iframe,
For example, <iframe id = "framelink" name = "framelink" frameBorder = "0" scrolling = "no" width = "0" height = "0"> </iframe>
And modify the link to: <a href = "www.jb51.net" onclick = "showModify (this)" class = "touPiao" target = "framelink"> I want to vote 1111 </a>
In this way, after the page is loaded, the page is simulated and clicked.