SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2009
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    slient javascript url redirection

    hi

    I need to redirect the user to another url in 5 seconds without the "click" sound.

    you'll notice that this:

    Code JavaScript:
    setTimeout("location.href='http://myurl';",5000);

    produces a "click" sound (maybe only in IE).
    I want to avoid this sound in my code (I know this can be changed in windows in the user's computer).

    can it be done?

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    100 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by remonkal View Post
    I need to redirect the user to another url in 5 seconds without the "click" sound.

    ...

    can it be done?
    No.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2009
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    No.
    how about using a meta refresh tag (not javascript)? how about Ajax ?

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    100 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by remonkal View Post
    how about using a meta refresh tag (not javascript)? how about Ajax ?
    The click sound is from the web browser as it loads a new page.
    You do not have the power to change that.

    It might be possible to replace page content using Ajax, but that's normally for small sections. It's kind of drastic to use it to load the entire contents of some different web page.

    However, you could use an iframe, and point that iframe at a different web address. That would work.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2009
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    iframe method: the following makes a "click" sound as well:

    HTML Code:
    <iframe src="http://google.com/" id="iframeA"></iframe>

    Code JavaScript:
    setTimeout("document.getElementById('iframeA').src='http://yahoo.com';",5000);

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    100 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by remonkal View Post
    Ajax should work because it's a not a new page isn't it?
    That's right. See the previous post regarding Ajax and iframes
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •