Results 1 to 3 of 3

Thread: Help me with pop up

  1. #1
    Join Date
    Feb 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Help me with pop up

    I need help with document write:
    I have this script :

    Code:
    <script type="text/javascript">
    <!--
    function dirtypop()
    {
    var generator=window.open('','name','height=500,width= 500,status=1,resizable=0');
    
    generator.document.write('<html><head><title>Popup </title>');
    generator.document.write('</head><body>');
    generator.document.write('<h1></h1>');
    generator.document.write('<p></p>');
    generator.document.write('<p><a href="java script:alert(self.location.href)">View the URL of this window</a>.</p>');
    generator.document.write('<p><a href="java script:self.close()">Close</a> the popup.</p>');
    generator.document.write('</body></html>');
    generator.document.close();
    }
    //-->
    </script>
    Code:
    <a href="java script:dirtypop();">Generate!</a>

    But i want in href a embed code inside , when somebody clicks on generate
    the pop up will be open with the embed code , and the pop up show it.

    Example :<a href="java script:dirtypop(<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/ebu0OBa1pus&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/ebu0OBa1pus&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>);">Generate!</a>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    First off:

    Code:
    <a href="java script:al . . .
    isn't right. There should be no space, but even so, unless you are unloading the page, you should use an onclick event.

    Now your real question is about passing a parameter to the page via the function that contains the HTML of an object/embed tag combo.

    You would probably be better off defining each possible (or just the one, if there is only one) such combo as a variable:

    Code:
    var pop_1='<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/ebu0OBa1pus&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/ebu0OBa1pus&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>';
    Then passing that off to the function:

    Code:
    <a href="alternate.htm" onclick="dirtypop(pop_1);return false;">Generate</a>
    The alternate.htm could have something on it for non-javascript enabled browsers.

    Here's the amended script (you could have a pop_2, a pop_3, and so on, if you like):

    Code:
    <script type="text/javascript">
    <!--
    
    var pop_1='<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/ebu0OBa1pus&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/ebu0OBa1pus&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>';
    
    function dirtypop(content)
    {
    var generator=window.open('','name','height=500,width= 500,status=1,resizable=0');
    
    generator.document.write('<html><head><title>Popup </title>');
    generator.document.write('</head><body>');
    generator.document.write('<h1></h1>');
    generator.document.write('<p></p>');
    generator.document.write('<p>'+content+'</p>');
    generator.document.write('<p><a href="javascript:self.close()">Close</a> the popup.</p>');
    generator.document.write('</body></html>');
    generator.document.close();
    }
    //-->
    </script>
    All this may still not avoid the 'click to activate' 'feature' (if that was even a consideration) in IE and Opera though, as that requires an external script, and this may or may not qualify as such to the browser.

    Incidentally, what happened when you tried to alert the location of a page that technically has no href? In my experience, you would get:

    about:blank

    or the href of the generating page.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Feb 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Thank you very much

    Quote Originally Posted by jscheuer1 View Post
    First off:



    isn't right. There should be no space, but even so, unless you are unloading the page, you should use an onclick event.

    Now your real question is about passing a parameter to the page via the function that contains the HTML of an object/embed tag combo.

    You would probably be better off defining each possible (or just the one, if there is only one) such combo as a variable:

    Code:
    var pop_1='<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/ebu0OBa1pus&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/ebu0OBa1pus&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>';
    Then passing that off to the function:

    Code:
    <a href="alternate.htm" onclick="dirtypop(pop_1);return false;">Generate</a>
    The alternate.htm could have something on it for non-javascript enabled browsers.

    Here's the amended script (you could have a pop_2, a pop_3, and so on, if you like):

    Code:
    <script type="text/javascript">
    <!--
    
    var pop_1='<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/ebu0OBa1pus&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/ebu0OBa1pus&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>';
    
    function dirtypop(content)
    {
    var generator=window.open('','name','height=500,width= 500,status=1,resizable=0');
    
    generator.document.write('<html><head><title>Popup </title>');
    generator.document.write('</head><body>');
    generator.document.write('<h1></h1>');
    generator.document.write('<p></p>');
    generator.document.write('<p>'+content+'</p>');
    generator.document.write('<p><a href="javascript:self.close()">Close</a> the popup.</p>');
    generator.document.write('</body></html>');
    generator.document.close();
    }
    //-->
    </script>
    All this may still not avoid the 'click to activate' 'feature' (if that was even a consideration) in IE and Opera though, as that requires an external script, and this may or may not qualify as such to the browser.

    Incidentally, what happened when you tried to alert the location of a page that technically has no href? In my experience, you would get:

    about:blank

    or the href of the generating page.



    Thank you very much saved money.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •