Tony Webb
07-04-2012, 07:14 PM
I don't know any js coding. I've just copied these snipets from other sites and tinkered with them. The code works when embedded into an html
I created the following code for a js file mobiles.js;
function detect_size()
{
if(screen.width<=650)
{
window.location="http://what-do-christians-believe.co.uk/mob_phone";
exit();
}
if(screen.width<=995)
{
window.location="http://what-do-christians-believe.co.uk/mob_devices";
exit();
}
if(screen.width<=995)
{
window.location="http://what-do-christians-believe.co.uk/book.html";
exit();
}
I then used the following html code to get the js file read
<script src="mobiles.js" type="text/javascript"></script>
The code doesn't work as a seperate js file or it's not being read by my index.html file. I've only put the script code in the index.html file to test it.
What do I need to do to get the js code to work from an html file?
I've tried making the js file into a htm file and that hasn't worked either. I've also tried screaming, shouting and going for a bike ride!
Thanks.
I created the following code for a js file mobiles.js;
function detect_size()
{
if(screen.width<=650)
{
window.location="http://what-do-christians-believe.co.uk/mob_phone";
exit();
}
if(screen.width<=995)
{
window.location="http://what-do-christians-believe.co.uk/mob_devices";
exit();
}
if(screen.width<=995)
{
window.location="http://what-do-christians-believe.co.uk/book.html";
exit();
}
I then used the following html code to get the js file read
<script src="mobiles.js" type="text/javascript"></script>
The code doesn't work as a seperate js file or it's not being read by my index.html file. I've only put the script code in the index.html file to test it.
What do I need to do to get the js code to work from an html file?
I've tried making the js file into a htm file and that hasn't worked either. I've also tried screaming, shouting and going for a bike ride!
Thanks.