SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    open window Problem

    I have a site search script and would like to size and position the search results page generated by the script: width=400, height=600, left=200, top=50 with vertical and horizontal scroll bars. Is this doable?

    Below is the search results page description:

    page="<html><head><title>Search Results</title></head><body style='font-family:Arial;color:black;' bgcolor='white'><center><table border=0 cellspacing=10 width=80%>";

    Thanks,

    Ben

  2. #2
    SitePoint Evangelist nsj's Avatar
    Join Date
    Oct 2005
    Location
    Jamaica (W.I)
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
    function submitform(){ 
     var newwin=null;
    		var newwin =     window.open('','winname','scrollbars=no,resizable=no,status=yes');
    		newwin.moveTo(200,50);
    		newwin.resizeTo(400,600);
    		document.searchform.target='winname';
    		document.searchform.action='searchpage.php';
    		document.searchform.submit();
    		window.close();
    }
    
    <form name='searchform'>
    <input type='submit' name=submit' value='submit' onclick='submitform();'>
    </form>

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    You can specify "scrollbars=yes" in your window features, but they will only display if needed. Since you are specifying a percentage width for your table, the table will automatically resize to the 400 width you list for your window, so no horizontal scrollbars will be needed, and they won't display. As a result, your table will be very narrow and long. In order to get the scrollbars to show, you would need to specify an absolute width for your table, like 700px:
    Code:
    <html>
    <head><title>Search Results</title>
    </head>
    
    <body style='font-family:Arial;color:black;' bgcolor='white'>
    
    <table border=0 cellspacing=10 width=700px>
    
    <tr>
    <td></td><td></td>
    </tr>
    
    <tr>
    <td></td><td></td>
    </tr>
    
    </table>
    </body>
    </html>
    In the code below, the onsubmit event handler is used to intercept the action of submitting the form. Before allowing the form to sumbit to the server, the code opens up a blank popup window with scroll bars and the specified size and location. The popup window is also given a name to match the target attribute listed in the form tag. Subsequently, the action of submitting the form is allowed to continue, and the search results are displayed in the window targeted by the form, i.e. the blank popup window.
    Code:
    <html>
    <head><title></title>
    
    <script type="text/javascript" language="javascript">
    <!-- Hide from browsers without javascript
    
    function openResultsWindow()
    {
    	window.open("", "resultsWindow", "width=400,height=600,top=50,left=200,scrollbars=yes");
    	return true;  //continues submitting the form
    }
    
    // End hiding -->
    </script>
    </head>
    <body>
    
    <form target="resultsWindow" method="post" action="searchpage.php" onsubmit="openResultsWindow()">
    	
    	<input type="text" id="" />
    	<input type="submit" value="search" />
    
    </form>
    
    </body>
    </html>
    Last edited by 7stud; Oct 22, 2005 at 19:08.

  4. #4
    SitePoint Evangelist nsj's Avatar
    Join Date
    Oct 2005
    Location
    Jamaica (W.I)
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a small correction.

    ........
    <table border=0 cellspacing=10 width=700px>
    ........

    Should be
    <table border=0 cellspacing=10 style="width:700px;">
    or
    <table border=0 cellspacing=10 width=700>


    Sorry 7stud.


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
  •