Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript refresh problem

Status
Not open for further replies.

bigmac13

Technical User
Sep 26, 2002
22
US
i use the following code:

javascript:location='calendar.php'; window.open('date.php?dates=09272002', 'dates', 'HEIGHT=800, WIDTH=605, scrollbar=no, resizable=no')

now when it opens the new window, it also refreshes the original window, which causes is an error because of dynamically loaded php script.

any help?
 
I'm not completely sure what you're asking here. If you want the code to open a new window without going to "calendar.php", remove location='calendar.php'; from your code. If the problem is something else, maybe you could clarify a little.
 
ok... ignore my first post.

date.php is the window that the given javascript is in. when i click on the javascript link, i want slot.php to open up in a new window, which it does. however, it also refreshes the date.php window, which screws up the page because the correct php variables don't load. is there any way to make the code NOT refresh date.php?

<-- date.php -->
javascript:location='date.php'; window.open('slot.php?info=09272002110', 'newwin', 'HEIGHT=350, WIDTH=450, scrollbar=no,resizable=no')

thanks...

-mike
 
Just remove the highlighted:
javascript:location='date.php'; window.open('slot.php?info=09272002110', 'newwin', 'HEIGHT=350,
 
thanks for the help, but i forgot to mention one other thing. date.php is also a window that was opened by a javascript. so when i take out the location='date.php' line, the date.php window goes blank and just says [object] in it.
 
In general, I don't recommend trying to open new windows with JS from another script-generated windows.
 
You should put your code in an onclick event instead and add &quot;;return false&quot; to the end of the code to keep the link from actually going somewhere. If you absolutely need to use the &quot;javascript:&quot; way of doing it, remove the &quot;location='date.php'&quot; and put the window.open() method inside the void() function.
&quot;javascript:void(window.open(...))&quot;

The void function evaluates what's passed to it without returning anything. Whenever something is returned by whatever code you're running in the &quot;javascript:&quot; line, your browser assumes it's a URL and tries to go to it. That's why &quot;[Object]&quot; was showing up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top