By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,317 Members | 1,273 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,317 IT Pros & Developers. It's quick & easy.

split() one document.frames not allowed

P: n/a
Hi,

I want to split the result from
window.frames['data_frame'].document.location;, this in order to find
out which page is currently opened in the specific frame. When I do it
like this:
var source = window.frames['data_frame'].document.location;
// var source = "W3Schools is great!";

index_source = source.split('/');
IE gives an error that this method or property is not supported by this
object. When I check it on the other var it is accepted. Is there any
way I can make this work? I already tried to do it with
document.getElementById().src etc.. but that is not very reliable.

Thanks in advance, Maarten

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Lee
Muffinman said:

Hi,

I want to split the result from
window.frames['data_frame'].document.location;, this in order to find
out which page is currently opened in the specific frame. When I do it
like this:
var source = window.frames['data_frame'].document.location;
// var source = "W3Schools is great!";

index_source = source.split('/');
IE gives an error that this method or property is not supported by this
object.


The location attribute of a document is not a string (it's a Location object),
and so doesn't have a split() method. I believe the href attribute of Location
is a string, so:

window.frames['data_frame'].document.location.href.split('/');

should work.

Jul 23 '05 #2

P: n/a
Lee wrote:
Muffinman said:

Hi,

I want to split the result from
window.frames['data_frame'].document.location;, this in order to findout which page is currently opened in the specific frame. When I do itlike this:
var source = window.frames['data_frame'].document.location;
// var source = "W3Schools is great!";

index_source = source.split('/');
IE gives an error that this method or property is not supported by thisobject.
The location attribute of a document is not a string (it's a Location

object), and so doesn't have a split() method. I believe the href attribute of Location is a string, so:

window.frames['data_frame'].document.location.href.split('/');

should work.


document.location has been deprecated for years, replaced by
document.URL (read-only by spec, read/write in - you guessed it). A
window's Location object is found at window.location, although it
appears that virtually all browsers now map document.location to
window.location, possibly to avoid errors. Because of the importance of
[window.]location it can be read directly as a string, or replaced with
a string. Of course, it isn't a string, and one thing you can't get
away with, as Lee noted, is to invoke String object methods on it.
Could do this:

function getURL(doc)
{
var m = null;
if (m = doc.URL.match(/[^\/\\]+$/))
return m[0];
return '';
}

alert(getURL(frames.data_frame.document));

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.