popup error (javascript)

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

    popup error (javascript)

    I got 2 error from the following code below...
    1. I couldn't load up the picture since the picture is at
    (C:\company\ima ge\largePic.jpg )
    2. I got a page error in my 'index.html' when calling popup(x,x,x) for the
    2nd time.

    The code are as followed.
    Can anyone help please? Thank you very much~~

    Ben


    ~~~~~~~ INDEX.HTML ~~~~~~~~ (c:\company\ima ge\index.html)

    <html><head><ti tle>Megatone Inc.</title></head>
    <style language='javas cript'>
    <!--
    function popup(picName, chatWidth, chatHeight) {
    popup = window.open('/popup.html','po pup','left=50,t op=50');
    var loadedPic = picName;
    while(popup.doc ument.readyStat e != "complete") {}
    popup.resizeTo( chatWidth,chatH eight);
    popup.document. images.src=load edPic;
    popup.focus();
    };
    //-->
    </style></head><body>
    <A href="javaScrip t:popup('largeP ic.jpg','750',' 392')"><IMG
    src="smallPIc.j pg" align=center></A>
    </body></html>



    ~~~~~~~ POPUP.HTML ~~~~~~~~ (c:\)

    <html><head><ti tle>Megatone Inc.</title></head>
    <BODY marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>

    <table width='100%' height='100%' border=0><tr><t d align='center'
    valign='center' >
    <img name='images' src='' alt='Loading Picture'>
    </td></tr></table>

    </BODY><HTML>




  • Lasse Reichstein Nielsen

    #2
    Re: popup error (javascript)

    "Ben Wan" <bwan0425@roger s.com> writes:
    [color=blue]
    > <style language='javas cript'>[/color]

    <style type="text/javascript">

    The type attribute is required in HTML 4.
    [color=blue]
    > <!--[/color]

    HTML comments are not needed in Javascript.
    [color=blue]
    > function popup(picName, chatWidth, chatHeight) {[/color]

    Your global function is called "popup" ...
    [color=blue]
    > popup = window.open('/popup.html','po pup','left=50,t op=50');[/color]

    ... and here you assign a window to the global variable "popup",
    overwriting the function.
    [color=blue]
    > var loadedPic = picName;[/color]

    Why rename the variable? You can just use "picName".
    [color=blue]
    > while(popup.doc ument.readyStat e != "complete") {}[/color]

    Busy-waiting is a bad idea. It takes up ressources and binds the
    browser until it finishes (if it does!).

    If you insist on waiting until readyState goes "complete" (how many
    browsers supports that? Mozilla and Netscape 4 doesn't.)
    [color=blue]
    > popup.resizeTo( chatWidth,chatH eight);
    > popup.document. images.src=load edPic;[/color]

    Which image? I think you mean
    popup.document. images[0].src = picName;
    [color=blue]
    > popup.focus();
    > };
    > //-->
    > </style></head><body>
    > <A href="javaScrip t:popup('largeP ic.jpg','750',' 392')"><IMG
    > src="smallPIc.j pg" align=center></A>[/color]

    Don't use the javascript: pseudo protocol.
    <URL:http://jibbering.com/faq/#FAQ4_24>

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    Working...