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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.open stripping encoding

Status
Not open for further replies.

dougcranston

Technical User
Oct 5, 2001
326
US
If I use an <a> similar to:

<a href=" ME</a>

It delivers me to the appropriate page, but this is a one-way trip off my site.

However, I want to pop up a window and display the same page, and then allow them to close it.

I am calling the falling statement in my page:

<a href="javascript:newWindow('
However, what is displayed when I move my mouse over the link AND when I click the link and it errors, the link in the address field in the browser states:


The function being called is:

****************************************************************
Creates pop up window
***************************************************************/

function newWindow(sURL, sName, w, h) {
// your new window's width
var w = w || 640;
// your new window's height
var h = h || 480;
var sName = sName || ("win" + new Date().getTime());

var ah = window.screen.availHeight;
var aw = window.screen.availWidth;
var l = (aw/2) - (w/2);
var t = (ah/2) - (h/2);
var sAtts = "location=yes" +
",menubar=yes" +
",directories=no" +
",menubar=no" +
",resizable=yes" +
",scrollbars=yes" +
",copyhistory=no" +
",titlebar=no" +
",status=yes" +
",toolbar=no" +
",location=no" +
",height=" + h +
",width=" + w +
",top=" + t +
",left=" + l;

window.open(sURL, sName, sAtts);
}

My guess is that the window.open is doing the conversion.

Does anyone have any suggestions?

Have searched my books on this subject and the web, to no avail.

I really want to pop a window to display the information, and allow then to close it and remain on my site. (The information being displayed is from another server on our intranet.)

Thanks in advance.

Doug Cranston
 
Could you post your urls without the so we can see the changes that are being made? TT will shorten urls and add a ..., making it hard to see what the difference is.

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
cLFlaVA,

Per your request...I have tried to break it up.. with a couple of Carriage Returns to break them up.

If I use an <a> similar to:

<a href="
ldapOrgChart/ldapOrgChartC1.jsp?uid=uid%3D280649175%2C+ou%3DPeople%2C+o%3Dverizon.com">TEST ME</a>

It delivers me to the appropriate page, but this is a one-way trip off my site.

However, I want to pop up a window and display the same page, and then allow them to close it.

I am calling the falling statement in my page:

<a href="javascript:newWindow('
ldapOrgChartC1.jsp?uid=uid=280649175,+ou=People,+o=verizon.com,'popup',600,400);">

However, what is displayed when I move my mouse over the link AND when I click the link and it errors, the link in the address field in the browser states:


ldapOrgChartC1.jsp?uid=uid=280649175,+ou=People,+o=verizon.com

The function being called is:

****************************************************************
Creates pop up window
***************************************************************/

function newWindow(sURL, sName, w, h) {
// your new window's width
var w = w || 640;
// your new window's height
var h = h || 480;
var sName = sName || ("win" + new Date().getTime());

var ah = window.screen.availHeight;
var aw = window.screen.availWidth;
var l = (aw/2) - (w/2);
var t = (ah/2) - (h/2);
var sAtts = "location=yes" +
",menubar=yes" +
",directories=no" +
",menubar=no" +
",resizable=yes" +
",scrollbars=yes" +
",copyhistory=no" +
",titlebar=no" +
",status=yes" +
",toolbar=no" +
",location=no" +
",height=" + h +
",width=" + w +
",top=" + t +
",left=" + l;

window.open(sURL, sName, sAtts);
}

My guess is that the window.open is doing the conversion.

Does anyone have any suggestions?

Have searched my books on this subject and the web, to no avail.

I really want to pop a window to display the information, and allow then to close it and remain on my site. (The information being displayed is from another server on our intranet.)

Thanks in advance.
 
doug,

What is the error message?

Before delving deeper into your code, make sure you have a close-single-quote following the URL in your function call.

--Dave
 
So, you're saying that

iweb2 changes to eweb2

/ldapOrgChart/ldapOrgChart/ldapOrgChartC1.jsp changes to
ldapOrgChart/ldapOrgChartC1.jsp

?

There are many things that can be wrong, if the above were not typos in your post.

eweb2 should be iweb2.
there should be a second directory (ldapOrgChart).

Additionally, you never close your single-quote in your call to the function:

Code:
<a href="javascript:newWindow('[green][http://][/green][red]i[/red]web2.verilux.com:88/ldapOrgChart/[red]ldapOrgChart/[/red]ldapOrgChartC1.jsp?uid=uid=280649175,+ou=People,+o=verizon.com[red]'[/red],'popup',600,400);">

Finally, you can remove "javascript:" from your code. It's not necessary.

Note: I put the http: in [] so that it wouldn't make a link.

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
cLFlaVA, and others..

When I pasted the readable version, I did not "change" the addressing as I did in my original post. It was a failed bit of trying to make it a little more generic... Sorry for that.

The addressing/wording in the "readable version" is correct.

Agreed in the posted version you pointed out that it was missing a closing single quote. I can assure you in the source and what I pasted, it did include the single quote. Possibly the way I broke up the text in creating the second version to enable you to see the full text, that somehow it got stripped by the faq program..

I appreciate your taking a shot at it.

DougC



 
I want to pop up a window and display the same page, and then allow them to close it.
Pardon me if I'm missing something, but if that's all you want to do, is there some reason why simply specifying the target in the link isn't sufficient, rather than using Javascript at all? The html would be:
Code:
<a href="[URL unfurl="true"]http://iweb2.verilux.com:88/ldapOrgChart/ldapOrgChart/ldapOrgChartC1.jsp?uid=uid%3D280649175%2C+ou%3DPeople%2C+o%3Dverizon.com"[/URL] target="_BLANK">TEST ME</a>
Unless I'm missing something about your requirements, this simple change may be all your need - it's the standard method used for off-site links on many, many pages. The new window will be the standard size that the user's browser normally opens, and your page's window will be underneath and unaffected. They will know they have to close the new window because its Back button will be greyed out (nothing to go back to). Also, this will work even if the user has scripting turned off. Just a thought - why make it harder than necessary?
 
OsakaWebbie,

Thank you for your suggestion. Yes, that would work, except I am looking for a popup window.

I just found a reference that triggered a thought. I have solved my problem by adding an encoding function.. The code is a little rough as I just "slammed" in a reference just to test my theory.

It was the code starting with the second uid=.... that needed to be encoded... Will clean up the function and calls.

Thanks for everyones help and suggestions...

Have a great day.

Dougc :)



/***************************************************************
* FILENAME : openwind.js *
* DESCRIPTION : Function to create a popup window *
* MODIFIED : 9/3/2003 D. Cranston *
****************************************************************
****************************************************************
Creates pop up window
***************************************************************/

function newWindow(sURL, sName, w, h) {
// your new window's width
var w = w || 640;
// your new window's height
var h = h || 480;
var sName = sName || ("win" + new Date().getTime());

var ah = window.screen.availHeight;
var aw = window.screen.availWidth;
var l = (aw/2) - (w/2);
var t = (ah/2) - (h/2);
var sAtts = "location=yes" +
",menubar=yes" +
",directories=no" +
",menubar=no" +
",resizable=yes" +
",scrollbars=yes" +
",copyhistory=no" +
",titlebar=no" +
",status=yes" +
",toolbar=no" +
",location=no" +
",height=" + h +
",width=" + w +
",top=" + t +
",left=" + l;

var tst = "
var ecode = URLEncode("uid=280649175,+ou=People,+o=verizon.com");

window.open(tst + ecode, sName, sAtts);
// window.open(sURL, sName, sAtts);
}
 
dougcranston:
Glad you have it sorted, but take a look at OsakaWebbie's code again:
Code:
<a href="[URL unfurl="true"]http://iweb2.verilux.com:88/ldapOrgChart/ldapOrgChart/ldapOrgChartC1.jsp?uid=uid%3D280649175%2C+ou%3DPeople%2C+o%3Dverizon.com"[/URL] [b]target="_BLANK"[/b]>TEST ME</a>

Note the [tt]target[/tt] attribute. [tt]target="_BLANK"[/tt] means open this page in a new window.

--Chessbot

"So it goes."
Kurt Vonnegut, Slaughterhouse Five
 
Note the target attribute, which is depricated in XHTML 1.0.

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Deprecated in XHTML 1.0 Strict, I believe.

--Chessbot

"So it goes."
Kurt Vonnegut, Slaughterhouse Five
 
lol yes.

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
<rhetorical>
Why was it ever deprecated? It is so useful...
</rhetorical>

--Chessbot

"So it goes."
Kurt Vonnegut, Slaughterhouse Five
 
<full-agreement>
Yeah what's the deal?
</full-agreement>

<did-you-know>
They're supposedly bringing it back in xhtml 2 strict.
</did-you-know>

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
<aside>
Why do people use html tags in posts? Is this the sign of someone who has gone over the edge?
</aside>

<reply>
Good, I should hope so.
</reply>

--Chessbot

"So it goes."
Kurt Vonnegut, Slaughterhouse Five
 
Sometimes it seems that about half the typical html used is deprecated in the newest standards - it'll be a LOOOONG time, if ever, before all that stuff stops being used.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top