Email:   
Home
In This Issue
EasyPrint
Click here for the RSS feed's XML code. This is not a browser URL.
Using JavaScript to get the Query_String from a frameset (continued)

I knew I could pass the parameters I needed to customize the home pages via a Query_String, but the Query_String I had to pass the parameters to was the frameset Query_String, not the Query_String of the form itself. I therefore had to figure out how I was going to get the Query_String of the frameset from within a form that was contained in one of the frames of the frameset.

Confused yet? OK, let me stop for a moment to clear this all up. In the scenario I described above where I have a frameset composed of three frames, I actually have four Query_Strings, one for each of the frames and one for the frameset itself. In my case, I had only one form in the main body frame that needed to be customized, but I couldn't pass parameters to it directly because I could only pass them to the frameset URL. Therefore, the form needed to be able to reach up to the Query_String for the frameset and grab the parameters from there.

In order to get the Query_String of the frameset, you have to think in JavaScript. By following the JavaScript DOM (Document Object Model), you can see that the correct way to get the Query_String from within a frame in a frameset is to go through the window object as follows: window.top.location.search. Here is the code I use in order to get the frameset Query_String (which I include in the JS Header section of the form). Note that I give it a default value if it doesn't have any value to begin with, in order to prevent errors when it's passed to the "getParameter" function.

var framesetQuery = "";
if ( window.top.location.search != 0 ) {
framesetQuery = window.top.location.search;
} else {
framesetQuery = "?OpenFrameset";
}

Extracting values passed via the URL: The "getParameter" function
Now that you have a handle on the Query_String for the frameset, you are ready to pass it to another function called "getParameter" which will actually extract the value of the parameter you specify. Here is the code for the "getParameter" JavaScript function you should include in the JS Header section of your form:

function getParameter ( queryString, parameterName ) {
// Add "=" to the parameter name (i.e. parameterName=value)
var parameterName = parameterName + "=";
if ( queryString.length > 0 ) {
// Find the beginning of the string
begin = queryString.indexOf ( parameterName );
// If the parameter name is not found, skip it, otherwise return the value
if ( begin != -1 ) {
// Add the length (integer) to the beginning
begin += parameterName.length;
// Multiple parameters are separated by the "&" sign
end = queryString.indexOf ( "&" , begin );
if ( end == -1 ) {
end = queryString.length
}
// Return the string
return unescape ( queryString.substring ( begin, end ) );
}
// Return "null" if no parameter has been found
return "null";
}
}




[ Prev | Next ]

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
-- Advertisement --

2-Minute Tutorials
How do I...

  • integrate MS Office or OpenOffice with Notes?
  • create cross-tab reports and charts?
  • print serial letters and mailing labels?
  • create PDFs in Lotus Notes?


Check out the 2-minute tutorials here.
-- Advertisement --

DEPARTMENT CALENDAR - MANAGE AND SHARE A COMMON CALENDAR WITH YOUR TEAMS
Are you responsible for improving your organization's Group Calendaring tool? Have you been tasked to find a true group calendar tool with Itinerary, Time-Off, Sign In/Out and Bulletins/Events module that seamlessly integrates with Domino calendaring?

If so, Logic Springs Technologies will make answering these questions a whole lot easier!

Learn how by visiting us at www.departmentcalendar.com

Copyright © 1998-2008, ZATZ Publishing. All rights reserved worldwide.
Editor's Login