image popup window title

Discussion in 'Javascript' started by skim1114@gmail.com, Jun 11, 2006.

  1. Guest

    I have this code in my popup window, which works perfectly except that
    I need it to display a new title for every image.

    Here the popup window code:
    <HTML>
    <HEAD>
    <TITLE>DETAIL</TITLE>
    <script language='javascript'>
    var temp=self.location.href.split("?");
    var picUrl = (temp.length>1)?temp[1]:"";
    var NS = (navigator.appName=="Netscape")?true:false;

    function fitPic() {
    iWidth = (NS)?window.innerWidth:document.body.clientWidth;
    iHeight = (NS)?window.innerHeight:document.body.clientHeight;
    iWidth = document.images[0].width - iWidth;
    iHeight = document.images[0].height - iHeight;
    window.resizeBy(iWidth, iHeight-1);
    self.focus();
    };
    </script>
    </HEAD>
    <BODY bgcolor="#FFFFFF" onload='fitPic();' topmargin="0"
    marginheight="0" leftmargin="0" marginwidth="0">
    <script language='javascript'>
    document.write( "<img src='" +picUrl +"' border=0>" );
    </script>
    </BODY>

    </HTML>

    I know it's somewhere in the document.write part, but i'm not sure. So
    if my image link is:
    javascript:popupPic('images/large1/detail/6detail_03.jpg','new popup
    title')

    It will insert the image and place in the new title.

    Thanks
    , Jun 11, 2006
    #1
    1. Advertising

  2. Randy Webb Guest

    said the following on 6/11/2006 12:30 PM:
    > I have this code in my popup window, which works perfectly except that
    > I need it to display a new title for every image.


    Then do so.

    > Here the popup window code:
    ><HTML>
    ><HEAD>
    ><TITLE>DETAIL</TITLE>
    ><script language='javascript'>
    > var temp=self.location.href.split("?");
    > var picUrl = (temp.length>1)?temp[1]:"";
    > var NS = (navigator.appName=="Netscape")?true:false;


    Ditch that code, it is not needed.

    >function fitPic() {
    > iWidth = (NS)?window.innerWidth:document.body.clientWidth;


    iWidth=(window.innerWidth)?window.innerWidth:document.body.clientWidth;

    No reliance on the unreliable userAgent string. Test for the feature you
    want to use.

    > iHeight = (NS)?window.innerHeight:document.body.clientHeight;


    Ditto.

    > iWidth = document.images[0].width - iWidth;
    > iHeight = document.images[0].height - iHeight;
    > window.resizeBy(iWidth, iHeight-1);
    > self.focus();
    > };
    > </script>
    > </HEAD>
    > <BODY bgcolor="#FFFFFF" onload='fitPic();' topmargin="0"
    > marginheight="0" leftmargin="0" marginwidth="0">
    > <script language='javascript'>
    > document.write( "<img src='" +picUrl +"' border=0>" );
    > </script>
    > </BODY>
    > </HTML>
    >
    > I know it's somewhere in the document.write part, but i'm not sure.


    No, it's not.

    document.title="new title with some caveats";

    > So if my image link is:
    > javascript:popupPic('images/large1/detail/6detail_03.jpg','new popup
    > title')


    Thats a bad way to write a link. Read the group FAQ with regards to
    using the javascript: pseudo-protocol.

    > It will insert the image and place in the new title.


    Only if PopupPic uses the second parameter as the title of the new
    window and passes it to the new page. But as written, it doesn't even
    use the first parameter it is passed.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
    Randy Webb, Jun 11, 2006
    #2
    1. Advertising

  3. Guest

    Thanks for the hints. Honestly, I gotta say, most of that went over my
    head and I am left still just as perplexed as before.



    Randy Webb wrote:
    > said the following on 6/11/2006 12:30 PM:
    > > I have this code in my popup window, which works perfectly except that
    > > I need it to display a new title for every image.

    >
    > Then do so.
    >
    > > Here the popup window code:
    > ><HTML>
    > ><HEAD>
    > ><TITLE>DETAIL</TITLE>
    > ><script language='javascript'>
    > > var temp=self.location.href.split("?");
    > > var picUrl = (temp.length>1)?temp[1]:"";
    > > var NS = (navigator.appName=="Netscape")?true:false;

    >
    > Ditch that code, it is not needed.
    >
    > >function fitPic() {
    > > iWidth = (NS)?window.innerWidth:document.body.clientWidth;

    >
    > iWidth=(window.innerWidth)?window.innerWidth:document.body.clientWidth;
    >
    > No reliance on the unreliable userAgent string. Test for the feature you
    > want to use.
    >
    > > iHeight = (NS)?window.innerHeight:document.body.clientHeight;

    >
    > Ditto.
    >
    > > iWidth = document.images[0].width - iWidth;
    > > iHeight = document.images[0].height - iHeight;
    > > window.resizeBy(iWidth, iHeight-1);
    > > self.focus();
    > > };
    > > </script>
    > > </HEAD>
    > > <BODY bgcolor="#FFFFFF" onload='fitPic();' topmargin="0"
    > > marginheight="0" leftmargin="0" marginwidth="0">
    > > <script language='javascript'>
    > > document.write( "<img src='" +picUrl +"' border=0>" );
    > > </script>
    > > </BODY>
    > > </HTML>
    > >
    > > I know it's somewhere in the document.write part, but i'm not sure.

    >
    > No, it's not.
    >
    > document.title="new title with some caveats";
    >
    > > So if my image link is:
    > > javascript:popupPic('images/large1/detail/6detail_03.jpg','new popup
    > > title')

    >
    > Thats a bad way to write a link. Read the group FAQ with regards to
    > using the javascript: pseudo-protocol.
    >
    > > It will insert the image and place in the new title.

    >
    > Only if PopupPic uses the second parameter as the title of the new
    > window and passes it to the new page. But as written, it doesn't even
    > use the first parameter it is passed.
    >
    > --
    > Randy
    > comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    > Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
    , Jun 12, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    520
  2. soonic
    Replies:
    11
    Views:
    1,772
    soonic
    Jul 27, 2011
  3. Jens Peter Hansen
    Replies:
    7
    Views:
    520
    Randy Webb
    Jun 19, 2004
  4. Raffi
    Replies:
    4
    Views:
    216
    Dr John Stockton
    Aug 12, 2004
  5. Russell
    Replies:
    2
    Views:
    277
    Russell
    Sep 13, 2004
Loading...

Share This Page