How do I use SetTimeOut inline?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • QA

    How do I use SetTimeOut inline?

    <img src=http://xxx.com/yyy.jpg
    onmouseover="se ttimeout(\"docu ment.location=' http://www.google.com' \"),
    2000">

    I want to have a 2 seconds delay before it is directed to an URL when the
    mouse is over the image.

    However, it seems that setTimtOut does not like parameters in the function
    part.


  • Lasse Reichstein Nielsen

    #2
    Re: How do I use SetTimeOut inline?

    "QA" <QA@alexa.com > writes:
    [color=blue]
    > <img src=http://xxx.com/yyy.jpg
    > onmouseover="se ttimeout(\"docu ment.location=' http://www.google.com' \"),
    > 2000">[/color]

    There are quite a lot of errors in these lines.

    First of all, the src attribute value must be quoted.

    In the "onmouseove r" attribute, since it is quoted (as it should be) with
    "'s, you cannot use "'s inside the value. Using Javascript escapes doesn't
    make a difference. You can either use &quot; instead of \" or switch
    to using single quotes.

    The function is called "setTimeout ", with that exact capitalization.

    The second parameter (2000) is not really a paremeter, since it is outside
    the parentheses.

    Try:

    <img src="http://xxx.com/yyy.jpg"
    onmouseover=
    "setTimeout('do cument.location =\'http://www.google.com/\'',2000);">

    or
    <img src="http://xxx.com/yyy.jpg"
    onmouseover=
    "setTimeout(&qu ot;document.loc ation='http://www.google.com/'&quot;,2000);" >
    [color=blue]
    > I want to have a 2 seconds delay before it is directed to an URL when the
    > mouse is over the image.[/color]

    What's wrong with clicking, now? :)
    [color=blue]
    > However, it seems that setTimtOut does not like parameters in the function
    > part.[/color]

    Sure it does. It just wants two of them.

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • QA

      #3
      Re: How do I use SetTimeOut inline?

      >[color=blue]
      > Try:
      >
      > <img src="http://xxx.com/yyy.jpg"
      > onmouseover=
      > "setTimeout('do cument.location =\'http://www.google.com/\'',2000);">
      >
      > or
      > <img src="http://xxx.com/yyy.jpg"
      > onmouseover=
      >[/color]
      "setTimeout(&qu ot;document.loc ation='http://www.google.com/'&quot;,2000);" >[color=blue]
      >[color=green]
      > > I want to have a 2 seconds delay before it is directed to an URL when[/color][/color]
      the[color=blue][color=green]
      > > mouse is over the image.[/color][/color]


      Thanks JS master!!!!

      I got another question: How do I open the window in a NEW window? I don't
      want to use window.open as it will be blocked as popup. I tried this:

      <img src="http://xxx.com/yyy.jpg"
      onmouseover=
      "setTimeout('do cument.location =\'http://www.google.com/\'',2000);"
      target=_blank>
      and this
      <a href="#" target=_blank>
      <img src="http://xxx.com/yyy.jpg"
      onmouseover=
      "setTimeout('do cument.location =\'http://www.google.com/\'',2000);">
      </a>

      I hope to use target="somenam e", does this automatically register somename
      as a frame/object? or I have to declare it first or use somename before i
      call it?



      Comment

      • Lasse Reichstein Nielsen

        #4
        Re: How do I use SetTimeOut inline?

        "QA" <QA@alexa.com > writes:
        [color=blue]
        > I got another question: How do I open the window in a NEW window? I don't
        > want to use window.open as it will be blocked as popup.[/color]

        You can expect any other way to open a window as a result of a mouseover,
        to also be blocked, if there is a popup blocker at all.

        Some blockers block all new windows, others only those not caused by
        a user input (typically a click, not simply a mouseover).
        [color=blue]
        > I tried this:
        >
        > <img src="http://xxx.com/yyy.jpg"
        > onmouseover=
        > "setTimeout('do cument.location =\'http://www.google.com/\'',2000);"
        > target=_blank>[/color]

        Img elements doesn't have a target attribute, so that won't help.
        [color=blue]
        > and this
        > <a href="#" target=_blank>
        > <img src="http://xxx.com/yyy.jpg"
        > onmouseover=
        > "setTimeout('do cument.location =\'http://www.google.com/\'',2000);">[/color]

        Changing the "document.locat ion" (which, btw, should probably be
        "window.locatio n" for maximum compatability) has nothing to do with the
        link that happens to be around the image. So, again, a no go.
        [color=blue]
        > I hope to use target="somenam e", does this automatically register somename
        > as a frame/object?[/color]

        If you click on a link with a target attribute (or otherwise open a
        link in a named target), a window is created with that name if it
        doesn't exist already. Nothing happens before you click, though.
        [color=blue]
        > or I have to declare it first or use somename before i call it?[/color]

        No declaration is necessary.

        Ok, one solution that doesn't use window.open, and tries to open
        in a new window:
        ---
        <a id="hiddenLink " name="hiddenLin k" href="http://www.google.com& "
        target="someTar get" style="display: none"></a>
        <img src="..."
        onmouseover="se tTimeout('docum ent.links.hidde nLink.click()', 2000);">
        ---
        A good popup blocker will stop it anyway, so good luck :)

        /L
        --
        Lasse Reichstein Nielsen - lrn@hotpop.com
        DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
        'Faith without judgement merely degrades the spirit divine.'

        Comment

        • Java  script  Dude

          #5
          Re: How do I use SetTimeOut inline?

          "QA" <QA@alexa.com > wrote in message news:<B2m1d.126 93$vcv.5945@new s01.bloor.is.ne t.cable.rogers. com>...[color=blue]
          > <img src=http://xxx.com/yyy.jpg
          > onmouseover="se ttimeout(\"docu ment.location=' http://www.google.com' \"),
          > 2000">
          >
          > I want to have a 2 seconds delay before it is directed to an URL when the
          > mouse is over the image.
          >
          > However, it seems that setTimtOut does not like parameters in the function
          > part.[/color]

          Inline JS is not the problem, it is your casing of the word
          setTimeout. Capitalize the `T` in Timeout.

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: How do I use SetTimeOut inline?

            Lasse Reichstein Nielsen wrote:
            [color=blue]
            > "QA" <QA@alexa.com > writes:[color=green]
            >> <img src=http://xxx.com/yyy.jpg [...]>[/color]
            >
            > There are quite a lot of errors in these lines.
            >
            > First of all, the src attribute value must be quoted.[/color]

            *This* "src" attribute value must be quoted
            because it contains a "/" (slash) character.


            PointedEars
            --
            Never trust anything you buy with good intentions

            Comment

            Working...