vanessa19
03-05-2005, 02:12 AM
Hi all,
I am attempting to learn something here.
I have a javscript that works fine when I put it in the BODY of my page:
var resSize
if (screen.width < 690)
{
resSize = "640x480"
}
else if (screen.width < 850)
{
resSize = "800x600"
}
else if (screen.width < 1079)
{
resSize = "1024x768"
}
else if (screen.width < 1200)
{
resSize = "1152x864"
}
else if (screen.width < 1330)
{
resSize = "1280x960"
}
else if (screen.width >= 1600)
{
resSize = "1600x1200"
}
{
document.write('<a href="thispage_' + resSize + '.html">')
}
However, I need to use the document.write method multiple times on the page, so, to make things more concise, I'd like to separate the script into two :
In the HEAD of my page:
var resSize
if (screen.width < 690)
{
resSize = "640x480"
}
else if (screen.width < 850)
{
resSize = "800x600"
}
else if (screen.width < 1079)
{
resSize = "1024x768"
}
else if (screen.width < 1200)
{
resSize = "1152x864"
}
else if (screen.width < 1330)
{
resSize = "1280x960"
}
else if (screen.width >= 1600)
{
resSize = "1600x1200"
}
And in the BODY of my page:
{
document.write('<a href="thispage_' + resSize + '.html">')
}
However, if I do that, nothing seems to happen at all. What am I doing wrong?
Thanks,
Vanessa
I am attempting to learn something here.
I have a javscript that works fine when I put it in the BODY of my page:
var resSize
if (screen.width < 690)
{
resSize = "640x480"
}
else if (screen.width < 850)
{
resSize = "800x600"
}
else if (screen.width < 1079)
{
resSize = "1024x768"
}
else if (screen.width < 1200)
{
resSize = "1152x864"
}
else if (screen.width < 1330)
{
resSize = "1280x960"
}
else if (screen.width >= 1600)
{
resSize = "1600x1200"
}
{
document.write('<a href="thispage_' + resSize + '.html">')
}
However, I need to use the document.write method multiple times on the page, so, to make things more concise, I'd like to separate the script into two :
In the HEAD of my page:
var resSize
if (screen.width < 690)
{
resSize = "640x480"
}
else if (screen.width < 850)
{
resSize = "800x600"
}
else if (screen.width < 1079)
{
resSize = "1024x768"
}
else if (screen.width < 1200)
{
resSize = "1152x864"
}
else if (screen.width < 1330)
{
resSize = "1280x960"
}
else if (screen.width >= 1600)
{
resSize = "1600x1200"
}
And in the BODY of my page:
{
document.write('<a href="thispage_' + resSize + '.html">')
}
However, if I do that, nothing seems to happen at all. What am I doing wrong?
Thanks,
Vanessa