Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Split function giving Error! Pls Hlp!

Status
Not open for further replies.

Bernini

Programmer
Oct 26, 2004
98
0
0
MT
Hi all,

I have an iframe within my html page, and upon pressing a button i would like to do the following:

Code:
 var location = parent.mainframe.location;
 var lArray   = location.split("?");
 alert(lArray[1]);

where mainframe is the id of the iframe.

The error is givin on the second line of the code saying:
Object doesn't support this method or property

Any ideas?

Thanks
B
 
location is an object that doesn't have a split method.
location.href is the string you're after which will have the split method, ut what I really think you're after is this:
parent.mainframe.location.search.substring(1);

Adam

Pedro offers you his protection
 
Location is an object, not a string. If you cast it to a string you will be able to use the split command. Try this:
coincidentally, location is a keyword in javascript, you should consider using something else
Code:
var loc = parent.mainframe.location;
var lArray   = loc.split("?");
alert(lArray[1]);

-kaht

Do the chickens have large talons?
 
and of course I post w/o making the change.....
Code:
var loc = String(parent.mainframe.location);
var lArray   = loc.split("?");
alert(lArray[1]);

-kaht

Do the chickens have large talons?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top