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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirection a page to a url defines as variable?

Status
Not open for further replies.

dbartlett41

Programmer
Mar 21, 2006
9
CA
i am trying to use the following code but it doesent seem like i can place a variable in side it to redirect to a url that is a variable any idea why it doesent work

window.setTimeout('window.location=go; ',500);

where go is normally "
any ideas, thanks again dave
 
nope didn't work and i think you were missing a quote there?
i tried:
window.setTimeout('window.location=' + go', 500);
window.setTimeout('window.location="+ go", 500);
window.setTimeout('window.location="+ go"', 500);

what is the difference between single quote and double quote?
what is the format of the expression it can handel i cant find a sensable definition on it.
 
Try this?
[tt] window.setTimeout('window.location="'+ go + '"', 500);[/tt]
 
ok i tried this
but it didn't work
var go = "window.setTimeout('window.location=' + go, 2000)


i tried this also and it did work except it doesent selay the redirect for 2 seconds like i wanted any idea why??

var go = " window.setTimeout(window.location=" + go, 2000)
 
i got it to work by your advice tsuji but whats with all the extra quotes? is there a certain pattern ? whats the defining difference between double and single quotes???
 
There is no difference with quote/apos, just for satisfying the nesting. As to why the extras, the reasoning is this: setTimeout 1st argument is going to be "evaluated/compiled"---the commonly conceived wicked eval()---at the time it will run. Then it should receive a string of the form we usually see: window.location=" It won't be right normally if it receives window.location= That's how to memorize it, as far as I am concerned.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top