image tag script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • William Starr Moake

    #1

    image tag script

    I want to adapt the following alert script into an insert image dialog
    in my WYSIWYG editor, but I can't get it to write an image tag
    correctly.

    <head>
    <script>
    function getImageDims(im gurl)
    {
    var oImage = new Image();
    oImage.onload = new Function(
    'alert("<img src='+imgurl + ' width="+this.wi dth + "
    height="+this.h eight)'
    );
    oImage.src = 'file:///' + imgurl;
    }
    </script>
    </head>
    <body>
    <input type="file" name="load"> <input type="button" value="Get Image
    Data" onclick="getIma geDims(load.val ue)">

    The above produces the following image tag:
    <img src=C:WINDOWSDe sktopthumbnail. jpg width=100 height=148

    Although the URL is displayed correctly in the browse text field named
    "load," the onclick function fails to copy it correctly with the
    slashes in place. And when I try to add a > to close the image tag, I
    get error message "object expected" in the onclick line.

    Any ideas on how to salvage this script? The pattern of single and
    double quotes in the alert line doesn't make any sense to me and every
    time I alter one quote I get an error message.
  • Thomas 'PointedEars' Lahn

    #2
    Re: image tag script

    William Starr Moake wrote:[color=blue]
    > I want to adapt the following alert script into an insert image dialog
    > in my WYSIWYG editor, but I can't get it to write an image tag
    > correctly.
    >
    > <head>
    > <script>[/color]

    Should read

    <script type="text/javascript">
    [color=blue]
    > function getImageDims(im gurl)
    > {
    > var oImage = new Image();
    > oImage.onload = new Function(
    > 'alert("<img src='+imgurl + ' width="+this.wi dth + "
    > height="+this.h eight)'
    > );
    > oImage.src = 'file:///' + imgurl;
    > }[/color]

    Indentation of blocks with two and/or four spaces would make your
    scripts easier legible.
    [color=blue]
    > </script>
    > </head>[/color]

    The HEAD element misses the TITLE element for the document to be valid HTML.
    [color=blue]
    > <body>
    > <input type="file" name="load"> <input type="button" value="Get Image
    > Data" onclick="getIma geDims(load.val ue)">[/color]
    ^^^^^^^^^^
    This is proprietary and error-prone referencing (using a
    pollution of the global namespace) as there is no object
    to be referenced with `load' except in the IE DOM. Use
    a FORM element and this.form.eleme nts.load.value instead.
    [color=blue]
    > The above produces the following image tag:
    > <img src=C:WINDOWSDe sktopthumbnail. jpg width=100 height=148[/color]

    It does because "\" is the escape character in J(ava)Script strings,
    and in the filename path "\" and the following character were not a
    valid escape sequence. Try to replace "\" with "/" prior to assignment
    to the "src" property as it is required for a valid (file-)URI.


    PointedEars

    P.S.
    Please explain this:
    | RCPT TO:<wsmoake@acm email.net>
    | 550 No such user (wsmoake) -ERR wsmoake@acmemai l.net not found

    Comment

    • Randy Webb

      #3
      Re: image tag script

      Thomas 'PointedEars' Lahn wrote:
      [color=blue]
      >
      > P.S.
      > Please explain this:
      > | RCPT TO:<wsmoake@acm email.net>
      > | 550 No such user (wsmoake) -ERR wsmoake@acmemai l.net not found[/color]

      It means you are still on your "please put out your true email address
      so that the auto-spammers can moer easily collect it" diatribes about
      proper/improper from: fields.

      --
      Randy
      Chance Favors The Prepared Mind
      comp.lang.javas cript FAQ - http://jibbering.com/faq/

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: image tag script

        Randy Webb wrote:[color=blue]
        > Thomas 'PointedEars' Lahn wrote:[color=green]
        >> P.S.
        >> Please explain this:
        >> | RCPT TO:<wsmoake@acm email.net>
        >> | 550 No such user (wsmoake) -ERR wsmoake@acmemai l.net not found[/color]
        >
        > It means you are still on your "please put out your true email address
        > so that the auto-spammers can moer easily collect it" diatribes about
        > proper/improper from: fields.[/color]

        Possibly the address does not exist, but lest you have forgotten, there
        is no diatribe. Standards clearly say what an e-mail address is and
        how the From: header must be composed. Who don't want to receive spam
        should send complaints to the Service Providers of spammers (watch the
        Received: headers), use Reply-To for private replies and a seldom-read
        but existing address in the From: and use e-mail filters (for both
        addresses); they should not disobey standards nor disregard Netiquette
        (if they want their postings to be read [by me]).


        EOD

        PointedEars

        Comment

        • Lee

          #5
          Re: image tag script

          Thomas 'PointedEars' Lahn said:
          [color=blue]
          > Who don't want to receive spam
          >should send complaints to the Service Providers of spammers[/color]

          Don't lock your door, just complain to the police
          when strangers walk into your home.

          Comment

          • Randy Webb

            #6
            Re: image tag script

            Thomas 'PointedEars' Lahn wrote:
            [color=blue]
            > Randy Webb wrote:
            >[color=green]
            >>Thomas 'PointedEars' Lahn wrote:
            >>[color=darkred]
            >>>P.S.
            >>>Please explain this:
            >>>| RCPT TO:<wsmoake@acm email.net>
            >>>| 550 No such user (wsmoake) -ERR wsmoake@acmemai l.net not found[/color]
            >>
            >>It means you are still on your "please put out your true email address
            >>so that the auto-spammers can moer easily collect it" diatribes about
            >>proper/improper from: fields.[/color]
            >
            >
            > Possibly the address does not exist, but lest you have forgotten, there
            > is no diatribe. Standards clearly say what an e-mail address is and
            > how the From: header must be composed. Who don't want to receive spam
            > should send complaints to the Service Providers of spammers (watch the
            > Received: headers), use Reply-To for private replies and a seldom-read
            > but existing address in the From: and use e-mail filters (for both
            > addresses); they should not disobey standards nor disregard Netiquette
            > (if they want their postings to be read [by me]).[/color]

            The address in my From: field is valid. Yet I do not recieve mail on it
            (with a few exceptions). The reason is very simple. Prior to me posting
            that address in Usenet, my spam was next to zero. After posting 10-12
            messages in Usenet, it went to almost 250 a day. So now, it does not
            recieve email (I am sure you tested it yet I will never see any sent
            mails to that address).

            What I don't understand, and maybe you can explain, is why it even
            matters whether you can email me or not? It shouldn't matter. Ask in
            Usenet, get answered in Usenet. When you take the conversation out of
            the context of the group, then you lose input as to possible
            flaws/fallacies in code/conversations.

            The irony is that you spend way more time worrying about attribution
            lines and from: headers in a week than most people should spend on them
            in 100 years. Its not going to change, its not going to matter. So
            please, for the sake of everyong, just let it go and keep moving on.


            --
            Randy
            Chance Favors The Prepared Mind
            comp.lang.javas cript FAQ - http://jibbering.com/faq/

            Comment

            Working...