Forum Moderators: open
function cPop(url, windowname, www, hhh) {
window.open(url,windowname,'width=' + www + ',height=' + hhh + ',left=30,top=70,screenX=30,screenY=70,resizable=yes,scrollbars=1,status=1');
}
And here's the HTML:
<a href="company-b/index.html" class="uo" onClick="cPop('company-b/index.html','company-b',750,400);return false" title="Company brochure">Company</a>
The idea is that visitors with javascript will get a pop-up window, and visitors without javascript still get the new page, only not in a pop-up window. And it's worked for me very nicely, up to this situation.
When the url parameter has a hyphen in the pathname, Explorer will not execute the jscript. Depending on the browser version, I get either a runtime error parsing the jscript, or I simply get the new page but not in a pop-up window. Explorer does just fine when there is no hyphen...but I've got a mess of already named directories to deal with here.
Does Explorer's jscript have a limitation on using a hyphen in a parameter name? Regular javascript - as found in Netscape, Moz and Opera - is having no problems. Or is there some other problem I'm missing.
So I bit the bullet and renamed all the directories and did global search and replace on all the references. Stupid, nasty, tedious work.
But I learned something to remember: keep hyphens out of your parameter values or IE will bite you.
[edited by: tedster at 10:15 am (utc) on April 12, 2003]
If you want to fix this without changing directory names, simply add the following replace to your function before the window.open is called
windowname = windowname.replace("-","_"); That will replace any hyphens with an underscore which shouldn't cause you any problems.
Any function that tries to subsequently work with these windows (which is why I'm assuming they're being named so specifically) will have to do the same.
J
I did want exact consistency between urls and windownames for ease of further coding. So dropping all the hyphens and concatenating the parameter's letters (which I just finished doing) will work out OK in this case, so I'm not about to dive into the mess again. Unfortunately it slightly diguises exactly who "Company" is, but I'll live with that.
I must say it feels good to know exactly what the issue was. Wow, I can't believe how helpful you members can be - I've been here a good while now, and it still amazes me.
I was midway through responding with "...I have not had a problem loading pop-ups with IE with hyphens in the url, using pretty much the same code...". Got called away from the keyboard for an hour, and see that my message is now redundant...
So instead I'll add this:
If you aren't too bothered about the exact size of the pop-up screen, and you aren't hiding the toolbars or status line, you don't really need the Javascript. You could just use:
<a href="company-b/index.html" class="uo" target="company_b" title="Company brochure">Company</a>
Even if you do want the exact size of the pop-up, it would be good to put the target in for non-Javascript browsers.
Shawn