SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Jan 2007
    Location
    Romania
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    differences in window.location.replace (or window.open) and a click on <a href...>

    Hi,

    I found that is a difference between using window.open (or window.location.replace) with setTimeout and a simple click on an <a href...>: if I use
    Code:
    setTimeout("window.location.replace('http://www.example.net/code?param1=1&param3=3', 5000);
    I will not be redirected on the correct page. Instead if I use a simple link to http://www.example.net/code?param1=1&param3=3 when the user clicks it goes to the correct page. How can this be avoided? I imagine that the difference is made on server side but I don't know what is it. What do you know about this?

  2. #2
    SitePoint Addict
    Join Date
    Jan 2007
    Location
    Romania
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It was a confusion. The links are in this format: http://www.ratestogo.com/enter.asp?i...DEUR%26lc%3DEN and are working in this format. Instead, on the page where I was making the transfer I was using escape against the link and was not good anymore.

  3. #3
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You were missing two characters. Try this:
    Code:
    setTimeout("window.location.replace('http://www.example.net/code?param1=1&param3=3')", 5000);
    I am concerned that your code may not be following JavaScript Best Practices. I recommend you read up on them.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  4. #4
    SitePoint Addict
    Join Date
    Jan 2007
    Location
    Romania
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kravvitz View Post
    You were missing two characters. Try this:
    Code:
    setTimeout("window.location.replace('http://www.example.net/code?param1=1&param3=3')", 5000);
    I am concerned that your code may not be following JavaScript Best Practices. I recommend you read up on them.
    I think you refer to the automatic redirection of the user to an external page. Well, the user makes a search, he finds what he wants and when he clicks the link a new window will be opened announcing him that will be redirected to another site where he can finish his transaction in a secured environment. He also has a text link to that page in case JavaScript is stopped.

    Your recommendation is very good although.

    Anyway, I changed the redirection mode to meta. You think it's better than using setTimeout?

  5. #5
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've used both at one time or another. Using a meta element to do it might be slightly more reliable. I'm glad you're including a text link as well.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •