Forum Moderators: open
1. alert(window.location.href.indexOf("first"));
2. if (window.location.href.indexOf("first")!= -1)
3. {
4. window1=window.open('','name','height=400,width=650');
5. ...
6. }
7. window1.close();
8. alert(window.location.href.indexOf("first"));
9. if (window.location.href.indexOf("second")!= -1)
10. {
11.alert(window1.document.getElementById("nametxt").length);
12. }
the statement
window.location.href.indexOf
works in 1,2 line
but shows an error in 8th line as
variable uses an Automation type not supported in Js
I dont know y it occurs..
plz give me solution..
Thanks in advance,
SweetJS
1. alert(window.location.href.indexOf("first"));
2. if (window.location.href.indexOf("first")!= -1)
3. {
4. window1=window.open('','name','height=400,width=650');
5. ...
6. }
7. window1.close();
8. //alert(window.location.href.indexOf("first"));
8.a alert(window.location);
8.b alert(window.location.indexOf("first"));
9. if (window.location.href.indexOf("second")!= -1)
10. {
11.alert(window1.document.getElementById("nametxt").length);
12. }
output of the line 8a gives the complete url ..( if second window not closed can we get the url of the first window? )
so i tried 8b to get the index..but it shows the same error.
1) It still seems that window1 is opened on condition (ie not always), yet there is a statement that calls for it to be closed that will always be executed. Presumeably this statement will cause an error if window1 was not opened (ie condition evaluates false).
2) window.location.indexOf("first");
This is an error. locatio is an object, and has no indexOf method.
( OK, loaction can be assigned a url: location = "page.htm", but this is accommodated by an internal setter method )
Always use location.href to be sure of getteing a string
window.location.href.indexOf("first");