Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    popup to internal code in same file?

    so i have code to make a popup via javascript and it works fine, but what actually pops up is an external file that i select (in my case test.html). i want all of the code of test.html to be in my index.html and when i call the popup it doesn't call an external file but instead calls the html code in the internal file (index.html)? possible?

    Code:
    <head>
    <script language="javascript" type="text/javascript">
    function popitup(url) {
    	newwindow=window.open(url,'name','status = 0,resizable = 0,height=500,width=600');
    	if (window.focus) {newwindow.focus()}
    	return false;
    }
    </script>
    </head>
    <body>
    <a href="test.html" onclick="return popitup('test.html')">About</a>
    </body>
    what's in test.html? it's a form
    why? i need the code of test.html to access some global javascript variables in index.html

  • #2
    Regular Coder
    Join Date
    May 2009
    Posts
    425
    Thanks
    3
    Thanked 62 Times in 61 Posts
    If you need to access js variables in both the form and the original page, instead of popping up a brand new window with the form, popup a fixed div on top of the original page. As far as I know, there's no quick and easy way (of which is cross-browser compatible) to share javascript across separate windows.

    I'll whip up something real quick that should work for you.

    PHP Code:
    <!DOCTYPE html>
    <
    html>
        <
    head>
            <
    title>Test</title>
            <
    style type="text/css">
                
    #test {
                    
    display:none;
                    
    position:fixed;
                    
    height:300px;
                    
    width:360px;
                    
    top:100px;
                    
    left:50%;
                    
    margin-left:-200px;
                    
    padding:20px;
                    
    background:#ff0000;
                    
    text-align:center;
                    
    z-index:999;
                }
                
    {
                    
    cursor:pointer;
                    
    cursor:hand;
                }
            </
    style>
            <
    script language="javascript" type="text/javascript">
                function 
    Show(id) {
                    
    document.getElementById(id).style.display 'block';
                }
            
    </script>
        </head>
        <body>
            <div id="test">
                <h1>Here's your form</h1>
                <form method="post">
                    <input type="text" name="Etc">
                    <input type="submit" name="Submit" value="Submit">
                </form>
            </div>
            <a onclick="Show('test');">About</a>
        </body>
    </html> 
    Last edited by tfburges; 07-08-2011 at 08:05 PM.
    I'm the founder of Loggur, a place to build and share web apps focused on maximizing efficiency and productivity:
    http://www.loggur.com

    My personal site and blog:
    http://www.tfburgess.com

  • #3
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    3,772
    Thanks
    23
    Thanked 550 Times in 549 Posts
    tfburges got there first..


  •  

    Posting Permissions

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