View Full Version : OnSubmit - Allowing for Scroll Bars on popup window??
camarosource
03-31-2007, 05:29 AM
What do I add to this ONSUBMIT script so it makes the popup window allow for SCROLL BARS if it's too high?
<FORM METHOD="POST" ACTION="http://www.camarosource.ca/list_the_rpos.php" name="form_rpo" onSubmit="postToPopup(500,335,this)">
I have a RPO code decoder. which when you click a Forum Submit button, a new window pops up and displays all the decoded RPO Codes into a new popup window. The WIDTH of the window is 335pixels, however the HEIGHT is currently set at 500pixels. The problem is that the page can EASILY and most of the time is, LARGER than this height. As a result the information below 500pixels is hidden. I want to be able to pop up scroll bars IF it's larger than 500pixels.
Someone posted that script above to me. But I never could figure out what the "postToPopup(500,335,this)"> statement, the "this" is for?? Obviously "500" is for a set height, 335 for set width.. but "this"?
And of course HOW to make the height NOT set so it allows scroll bars. Thanks
RysChwith
04-02-2007, 08:18 AM
The 'this' in that line is a reference to the form itself. Passing it to the script allows it to pull in information from the form.
As far as how to add scrollbars, that's going to be somewhere in the postToPopup function. Somewhere in there you'll see a line that starts with window.open (or possible somevariable = window.open). The open() function call is going to have three parameters. The third one will minimally have a height and width value (should look something like "width=335,height=500"). All you should have to do is add ",scrollbars=yes" to the end of that.
Rys
camarosource
04-02-2007, 02:47 PM
The 'this' in that line is a reference to the form itself. Passing it to the script allows it to pull in information from the form.
As far as how to add scrollbars, that's going to be somewhere in the postToPopup function. Somewhere in there you'll see a line that starts with window.open (or possible somevariable = window.open). The open() function call is going to have three parameters. The third one will minimally have a height and width value (should look something like "width=335,height=500"). All you should have to do is add ",scrollbars=yes" to the end of that.
Rys
Here is the code:
<FORM METHOD="POST" ACTION="http://www.camarosource.ca/folder/decoder.php" name="form_rpo" onSubmit="postToPopup(500,335,this)">
I tried both:
<FORM METHOD="POST" ACTION="http://www.camarosource.ca/folder/decoder.php" name="form_rpo" onSubmit="postToPopup(500,335,scrollbars=yes,this)">
And
<FORM METHOD="POST" ACTION="http://www.camarosource.ca/folder/decoder.php" name="form_rpo" onSubmit="postToPopup(500,335,this,scrollbars=yes)">
But it just now doesn't pop up a new resized window that allows scroll bars, rather it just loads it as a new page.
RysChwith
04-02-2007, 04:29 PM
You misunderstood me. The changes aren't going to be to the onsubmit handler; they're going to be inside the postToPopup function itself. Find where you have that function defined (either in a <script> block on this page or in an external JavaScript file) and make the changes there.
Rys
camarosource
04-02-2007, 04:38 PM
You misunderstood me. The changes aren't going to be to the onsubmit handler; they're going to be inside the postToPopup function itself. Find where you have that function defined (either in a <script> block on this page or in an external JavaScript file) and make the changes there.
Rys
Here is the code:
<script language="JavaScript" type="text/javascript">
function postToPopup(w,h,f) {
n = f.name;
window.open("javascript:opener.document." + n + ".submit()", f.target = 'wnd' + n, 'width=' + w + ',height=' + h);
return false;
}
</script>
camarosource
04-03-2007, 04:01 AM
help please?
RysChwith
04-03-2007, 08:23 AM
The important line is this one:window.open("javascript:opener.document." + n + ".submit()", f.target = 'wnd' + n, 'width=' + w + ',height=' + h);If you'll recall, I mentioned that window.open takes three parameters separated by commas.
If you look at the portion before the first comma, you have this:"javascript:opener.document." + n + ".submit()"That's the URL that will load in the new window.
The second parameter is this:f.target = 'wnd' + nThat's the name of the new window and is, as far as I've ever been able to determine, largely irrelevant.
The third parameter is this:'width=' + w + ',height=' + h(Note that the comma there is inside the quote marks and thus part of a string, not a parameter delimiter.) This is the one that defines the features of the window and the one to which you'll want to pay attention.
Adding the scrollbars thing is as simple as changing it to:'width=' + w + ',height=' + h + ',scrollbars=yes'I recommend fiddling with that until you're sure you understand it and asking any other questions about it you may have.
Rys
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.