Click to See Complete Forum and Search --> : <A href="javascript:help.html"> issues
crazyheffro
02-22-2003, 01:38 AM
I have the following in my script.
document.write('<BR><A href="javascript:window.open(\'day.html?'+VAR+'\')">'+VAR+'</A>');
This is for a calender. The proceding code is in the portion that displays the month, and when the link is clicked then it opens day.html; which displays the day. The problem is that when the link is clicked then the month calender disapears and the page says, "[object]". No Bueno.
How can I avoid this?
In an attenpt to fix it I had a link that opens a temporary page in a new window ( <A taget=_blank href="temp.html"> ). temp.html would then open day.html and close itself. I didn't like this because it seems messy and flashes a dead screen at the users.
Thanks. Keep in mind I started learning javascript 2 days ago.
-Jeffro
russ_man7
02-22-2003, 03:03 AM
it looks as if your variable is refrencing the wrong thing. without seeing more of the code, such as what goes into the variable, it's dang hard to come up with a reliable fix. post some more of your script, for instance where you set the variable. just a stab in the dark, i'm guessing you said something to the effect of var=day_pic[3] or new image() or something like that, which wouldn't give you a string, but the object itself. you would want the src, like day_pic[3].src, i think; others could give you better js vocabulary, but that's the best i can give you at 4 am. good luck.
crazyheffro
02-22-2003, 04:24 AM
I do not believe the problem is in my variable refrencing. It is passing the right variables and pulling up the day.html?VAR page fine, the problem is that the original page disapears.
Enough rambing on my part, here is an example of my problem:
http://www.mines.edu/students/j/jerobiso/jshelp/test.html
khalidali63
02-22-2003, 04:26 AM
The line of code you posted has some syntactical errors.
1.I would not want to use VAR as variable since its a JavaScript language keyword,use some other identifier.
2.There are single or double qoutes missing..
follow the pattern in the example below.
document.write('<BR><A href="javascript:window.open(\"day.html?'+variable+'\")">'+variable+'</A>');
cheers
Khalid
Charles
02-22-2003, 07:05 AM
Except that Khalid's example 1) Throws an error and 2) wouldn't solve the problem even if it didn't throw an error. The immediate problem is that the construct <a href="javascript:someScript()">Some Script</a> is wrong and always has been. And browsers have started to recover from that wrongedness by doing what Jeffro has observed.
There are a few ways around the problem but this one is preferred:
document.write('<br><a href="#">', variable, '</a>');
document.links.[document.links.length-1].onclick = function () {window.open('day.html?' + variable); return false}
And it goes without saying that you will be creating a page that will fail for the one in ten users who do not use JavaScript and for the countless others who have disabled pop-ups. And because that means that your page will be inaccesible to persons with certain disabilities you may find yourself running afoul of accessibility laws.