Search DominoPower's 11,441 Lotus-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Twitter Feed Click here for the Twitter feed.
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";
}
}


« Previous  ·  1  ·  2  ·  3  ·  4  ·  5  ·  Next »
Other articles you might like
Home > Internet Technologies > JavaScript (13 articles)
   Sorting your Domino views with JavaScript
   Give your Domino views life with DHTML
   Using dynamically generated HTML to thwart spam email address harvesting
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent DominoPower Articles
Application development, William Shatner, and the origin of the universe
Learn Domino Designer 8.5 for free
The (near) future of Sametime, Quickr, Connections, and Symphony
Inside the IBM Innovations lab
Lotusphere 2010: Hot fixes and cool news for Notes, Domino, and LotusLive
Lotusphere 2010: mobility and collaboration
2010: A Lotusphere of change
Latest Lotus Headlines
Xpages not loading? JVM errors? - Solution
How to implement an iCalendar feed into your Notes calendar with XPages
DWA Hotfixes for Domino 8.5.1FP1 - A Gotcha
IBM Adds DB2 to Lotus Foundations SMB Package
SNTT : XPages onclick Ghosts in the machine
Ports used by Lotus Sametime 8.5 servers
Exploring a Domino Date Bug
>> Read all the news
More from the ZATZ journals
Computing Unplugged: The iPad defenders have spoken
David Gewirtz Online: CNN commentary and analysis
OutlookPower: More about disappearing text
-- Advertisement --

Learn Notes and Domino 8 at your place and pace!
Learn Notes and Domino in your office and/or home! TLCC's highly acclaimed distance learning courses for users, developers, and admins will enhance your career and your resume.

The many included activities and demos will make you a pro! Expert instructor help is a click away.

Click here to try a FREE demo course!!

-- Advertisement --

Mark your calendar for in-depth Lotus training, May 12-14, Boston
Join experts and peers May 12-14 in Boston for educational and networking events that deliver real-world Lotus training so you can increase productivity and efficiency in your company, advance your skills, and squeeze the most from your current environment. One registration gets you into THE VIEW's Admin2010 and Lotus Developer2010.

Register by April 10 to save $200.
ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login