SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    popup not working

    I am trying to create a popup where the viewer clicks on the image to the right on this page:
    http://www.kripalu.org/article/378/
    to see an interview. It's not working. What am I missing?

    My code is:
    HTML Code:
            <script language="javascript" type="text/javascript">
            <!--
            
            var newwindow;
    function showinterview('/ytt_interview.php')
    {
        newwindow=window.open('/ytt_interview.php','ytt_interview','height=500,width=550,left=500,top=350,resizable=yes,scrollbars=yes');
        if (window.focus) {newwindow.focus()}
    }
            // -->
            </script>
    
    <h4>Some Text here</h4> 
    <a href="javascript:showinterview('/ytt_interview.php');"><img src="/uploads/images/15499081_YTT_Michael_qt.jpg" alt="YTT Interview" hspace="20" vspace="20" border="0" align="right" /></a>
    <p>More text here. More text here. ...</p>
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  2. #2
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Paul,

    Take a look at this:
    window.open

    First of all, you can't assign values to variables in the variablelist.
    So this is how you would do it:

    HTML Code:
    <script language="javascript" type="text/javascript">
    	<!--
    		var newwindow;
    		function showinterview(url, name)
    		{
    			newwindow=window.open(url,name,'height=500,width=550,left=500,top=350,resizable=yes,scrollbars=yes');
    			if (window.focus) {newwindow.focus()}
    		}
    	// -->
    </script>
    <h4>Some Text here</h4> 
    <a href="javascript:showinterview('ytt_interview.php','ytt-interview');"><img src="/uploads/images/15499081_YTT_Michael_qt.jpg" alt="YTT Interview" hspace="20" vspace="20" border="0" align="right" /></a>
    <p>More text here. More text here. ...</p>

  3. #3
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By the way, Paul, if your using Internet Explorer, you won't get many information about the errors that occur.
    Firefox has a Javascript Console where you can find lots of information when an error occurs.
    You can download Firefox freely at http://www.mozilla.com

    Have fun

  4. #4
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great! That works fine.
    http://www.kripalu.org/article/378/

    All I had to do was to add a / to the url. Otherwise the link was opening the YTT page instead of the interview page.

    One more thing. I have added a link to the interview page to allow the viewer to easily close the popup. It's not working. Again, what am I missing?

    My code in the interview page is:
    HTML Code:
     <p align="right"><a href="javascript:if (newwindow) newwindow.close()">Close</a> the popup.</p>
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  5. #5
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I realize I have left out the JavaScript for "newwindow." Haven't yet found a reference on the web how to handle this.
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  6. #6
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well Paul, it depends on from which window you want to close the popup.

    If you want to put a Close-button on the page http://www.kripalu.org/article/378/ you can use this:
    HTML Code:
    <p align="right"><a href="javascript:;" onClick="if (newwindow){newwindow.close();}">Close</a> the popup.</p>
    If you want to put a Close-button on the popup itself, you can use this:
    HTML Code:
    <p align="right"><a href="javascript:;" onClick="window.close();">Close</a> the popup.</p>
    Grtz, Vince


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
  •