faqts : Computers : Programming : Languages : JavaScript : Windows

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

21 of 56 people (38%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

I am unable to change the window location by using window.location.href or window.navigate when the
I am unable to change window's location by using window.location.href in Internet Explorer 5.5 SP2.

Dec 5th, 2001 13:15
Jean-Bernard Valentaten, Cory Powers,


Hi Cory,
if you showed us some code we might be able to help you.
Basically the window.location.href does work with IE5.5SP2 unless there
are some format-errors in the URL.
I guess you're composing the URL, passing information through queries.
Maybe you need to use the escape() function first, so that the URL is
formatted the right way.
If that doesn't work please show us some code, we'll try to isolate the
problem.
HTH,
Jean
Basically the problem only occurs when I am using a URL that is over 
2500 charcters long. window.open works with the long URL but 
window.location.href and window.navigate do not. Have you heard of this 
before? Is there some limitation on the URL length? I know that the URL 
length is limited to 8192 bytes on the server but I can't get any where 
near that. 
Sympton: The little world in IE will keep spinning after the call to 
window.location.href and the page is never updated.
Thanks,
Cory
Hmm, sounds strange. Could you show us some code? Maybe there is a 
problem in there that isn't really obvious.
Jean
I have a page that needs to be reloaded to refresh a user list when the 
user selects a different group in the drop down list. here is the 
function that reloads the page, I pass all of the current entries on 
the form as part of the query string so no data is lost. The problem 
detail can be up to 3000 charcters but I can't get it to work when I 
have more than 1800 characters in the problem detail.
function updatePage(field){
	nms = document.createTicket.nms.value;
	customerName = document.createTicket.customerName.value;
	customerPhone = document.createTicket.customerPhone.value;
	customerEmail = document.createTicket.customerEmail.value;
	groupCode = document.createTicket.groupCode.options
[document.createTicket.groupCode.selectedIndex].value;
	siteId = document.createTicket.siteId.options
[document.createTicket.siteId.selectedIndex].value;
	assignedToUser = document.createTicket.assignedToUser.options
[document.createTicket.assignedToUser.selectedIndex].value;
	agencyCode = document.createTicket.agencyCode.options
[document.createTicket.agencyCode.selectedIndex].value;
	docType = document.createTicket.docType.options
[document.createTicket.docType.selectedIndex].value;
	catCode = document.createTicket.catCode.options
[document.createTicket.catCode.selectedIndex].value;
	envCode = document.createTicket.envCode.options
[document.createTicket.envCode.selectedIndex].value;
	process = document.createTicket.process.value;
	priority = document.createTicket.priority.options
[document.createTicket.priority.selectedIndex].value;
	summary = escape(document.createTicket.summary.value);
	detail = escape(document.createTicket.detail.value);
	files = "";
	for(x=0; x<(document.createTicket.files.options.length); x++){
		files += "&files=" + escape
(document.createTicket.files.options[x].value);
	}
	var newURL = window.location.protocol + "//" + 
window.location.host + window.location.pathname;
	var queryString = "?
reloaded="+field+"&nms="+nms+"&customerName="+customerName+"&customerPho
ne="+customerPhone+"&customerEmail="+customerEmail+"&groupCode="+groupCo
de+"&siteId="+siteId+"&assignedToUser="+assignedToUser+"&agencyCode="+ag
encyCode+"&docType="+docType+"&catCode="+catCode+"&envCode="+envCode+"&p
rocess="+process+"&priority="+priority+"&summary="+summary; 
	var detail = "&detail="+detail+files;
	alert("New URL: " + newURL + "\n\nQuery String: " + queryString 
+ "\n\nLength: " + (newURL.length+queryString.length));
	alert("Detail: " + detail + "\n\nLength: " + detail.length);
//Doesn't work	window.navigate(newURL + queryString + detail);
	window.open(newURL + queryString + detail, 'temp'); //Works
//Doesn't work	window.location.href = newURL + queryString + detail;
}
Hi Cory,
well that's a pretty big thing :)
I see two bugs here.
First off, are you sure that your for-loop is doing the right thing.
What you'll get there is "&files=firstfile.xyz&files=secondfile.xyz"
You'll get a lot of queries that have the same name, so you won't be
able to sort them out anymore.
Now for the detail variable, first you use it and then you declare it.
Of course in some browsers this might work, but unless there's a global
var called detail, IE5.x might not take it.
Whenever you use variables that are not global in functions you have to
declare them using the var-keyword (js specification *g*).
Other than that I can't see anything wrong in there.
Depending on how you parse the query-string, the file-string could be
the problem here.
Try this:
for (x = 0; x < document.createTicket.files.options.length; x++)
{
  files += document.createTicket.files.options[x].value + ","
}
files = "&files=" + escape(files);
It might help, if not please e-mail me the whole html-document.
HTH,
Jean