I want to change the advertisement url for different browser/device viewport width. So far, I found a code to detect viewport width, I need detailed help to change the url. Thanks in advance!
This is the code for the viewport width:
Now, this is what I want to do:
This is the code for the viewport width:
Code:
var viewportwidth;
if (typeof window.innerWidth != 'undefined')
{
viewportwidth = window.innerWidth
}
else if (typeof document.documentElement != 'undefined'
&& typeof document.documentElement.clientWidth !=
'undefined' && document.documentElement.clientWidth != 0)
{
viewportwidth = document.documentElement.clientWidth
}
else
{
viewportwidth = document.getElementsByTagName('body')[0].clientWidth
}
Code:
if ( viewportwidth > 1024 )
{
use this ads: <SCRIPT SRC="url for big banner" type="text/javascript"></SCRIPT>
}
else {
use the ads:<SCRIPT SRC="url for small banner" type="text/javascript"></SCRIPT>
}
Comment