IE javascript:function() link error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • steephill.tv@gmail.com

    IE javascript:function() link error

    Some windows IE users encounter an error when launching javascript
    from my links. An error is generated before the window opens.
    For example:

    <a href="javascrip t:PlayCosmos('p r-08-highlights-eurosport','738 5866',
    13,4,2008);">On e Minute Race Highlights from Paris-Roubaix</a>

    function PlayCosmos(titl e, id, day, month, year) {
    url = 'http://cosmos.bcst.yah oo.com/up/player/popup/index.php?
    cl='+id;
    NewWindow(url,t itle,430,426,'n o');
    }

    function NewWindow(mypag e, title, w, h, scroll) {
    OpenWindow(mypa ge, title, w, h, scroll);
    win.window.focu s();
    }

    function OpenWindow(mypa ge, title, w, h, scroll) {
    var winl = parseInt((windo w.screen.width - w) / 2);
    var wint = parseInt((windo w.screen.height - h) / 2);
    winprops = 'height='+h+',w idth='+w+',top= '+wint+',left=' +winl
    +',scrollbars=' +scroll+',resiz able=no';
    win = window.open(myp age, title, winprops);
    }


    Anyone know why?

    There are other variations of javascripts links that don't work in my
    "Cycling video clip of the day" section on my home page:
    Alternative bike racing and touring reports with big photographs and action video from the most scenic cycling destinations around the world. Recreational reports from California, Hawaii, New Zealand, Italy and France. Pro Tour bike racing coverage of the Tour de France, Giro d'Italia and Amgen Tour of California to name a few.


    tia,
    Steve
  • RobG

    #2
    Re: IE javascript:func tion() link error

    On Apr 16, 7:21 am, steephill...@gm ail.com wrote:
    Some windows IE users encounter an error when launching javascript
    from my links. An error is generated before the window opens.
    For example:
    >
    <a href="javascrip t:PlayCosmos('p r-08-highlights-eurosport','738 5866',
    13,4,2008);">On e Minute Race Highlights from Paris-Roubaix</a>
    It does not seem sensible to create a reliance on script support when
    it isn't necessary.

    function PlayCosmos(titl e, id, day, month, year) {
    url = 'http://cosmos.bcst.yah oo.com/up/player/popup/index.php?
    cl='+id;
    NewWindow(url,t itle,430,426,'n o');
    }
    Consider instead (will break on wrapping):

    <a href="http://cosmos.bcst.yah oo.com/up/player/popup/index.php?
    cl=7385866"
    onclick="return playCosmos(this , 'pr-08-highlights-eurosport',
    '7385866',
    13,4,2008);"

    And the playCosmos function can be modified to suit, something like:

    function playCosmos(link , title, id, day, month, year) {
    NewWindow(link. href, title,430,426,' no');
    return false;
    }

    Now if the user has scripting disabled or not available, or the script
    fails to execute correctly, there's still a good chance they can view
    the clip and you've reduced your support requirements.

    A couple of comments:
    1. Why use 3 functions where one would do?
    2. It is usual to reserve functions names starting with capital
    letters for constructors.
    3. Don't try to position the pop-up, let it go where the user puts
    it. Consider someone with a desktop spread over two screens, your pop-
    up will be split between the two. Also, users with large or wide
    screens probably don't want a small movie in the center of the screen.


    --
    Rob

    Comment

    • steephill.tv@gmail.com

      #3
      Re: IE javascript:func tion() link error

      >A couple of comments:

      I'm using a javascript as an anchor because the page will become
      invalid in three months and I'll either redirect the user to another
      page or I'll provide a user-friendly message. In other words, I want
      control the implementation.

      I appreciate your detailed feedback, but you didn't address my
      question. Why doesn't the script work? Anyone know why?




      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: IE javascript:func tion() link error

        steephill.tv@gm ail.com wrote:
        >A couple of comments:
        >
        I'm using a javascript as an anchor because the page will become
        invalid in three months and I'll either redirect the user to another
        page or I'll provide a user-friendly message. In other words, I want
        control the implementation.

        I appreciate your detailed feedback, but you didn't address my
        question. Why doesn't the script work? Anyone know why?
        Because it can't. The `javascript:' URI scheme exists to return an HTML
        document string from a JavaScript expression. Neither does this need to be
        supported nor are you returning a HTML document string from PlayCosmos().


        PointedEars

        Comment

        • steephill.tv@gmail.com

          #5
          Re: IE javascript:func tion() link error

          On Apr 16, 5:24 pm, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
          wrote:
          steephill...@gm ail.com wrote:
          A couple of comments:
          >
          I'm using a javascript as an anchor because the page will become
          invalid in three months and I'll either redirect the user to another
          page or I'll provide a user-friendly message. In other words, I want
          control the implementation.
          >

          >
          I appreciate your detailed feedback, but you didn't address my
          question. Why doesn't the script work? Anyone know why?
          >
          Because it can't.  The `javascript:' URI scheme exists to return an HTML
          document string from a JavaScript expression.  Neither does this need tobe
          supported nor are you returning a HTML document string from PlayCosmos().
          >
          PointedEars
          Thanks for your answer. So why does this example from a Javascript
          reference site work:


          So should I return an empty string from PlayCosmos or should it be
          launched by the onclick event handler of the anchor?

          thanks,
          Steve

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: IE javascript:func tion() link error

            steephill.tv@gm ail.com wrote:
            [...] Thomas 'PointedEars' Lahn [...] wrote:
            >steephill...@g mail.com wrote:
            >>>A couple of comments:
            >>I appreciate your detailed feedback, but you didn't address my
            >>question. Why doesn't the script work? Anyone know why?
            >Because it can't. The `javascript:' URI scheme exists to return an HTML
            >document string from a JavaScript expression. Neither does this need to be
            >supported nor are you returning a HTML document string from PlayCosmos().
            >[...]
            >
            Thanks for your answer. So why does this example from a Javascript
            reference site work:
            http://www.web-source.net/javascript_popup_window2.htm
            If any such example works, then that should be considered a happy coincidence.

            This site does not deserve to be called a "Javascript reference site",
            whatever your understanding of the word "Javascript ". It promotes invalid
            markup, obsolete techniques, and content that does not degrade gracefully
            (i.e. is in violation of Section 508 and other accessibility guidelines and
            legislation), to say the least. And one can find that out by just looking
            at the example that you referred to. Guess what abominations of failed
            attempts at Web application development other parts of it might reveal ...
            So should I return an empty string from PlayCosmos or should it be
            launched by the onclick event handler of the anchor?
            You should do what Rob already recommended.


            PointedEars
            --
            Prototype.js was written by people who don't know javascript for people
            who don't know javascript. People who don't know javascript are not
            the best source of advice on designing systems that use javascript.
            -- Richard Cornford, cljs, <f806at$ail$1$8 300dec7@news.de mon.co.uk>

            Comment

            Working...