need help on openning a new window

Y

Yaqian

Hi, I want to open a new window without tool bar, address bar and status bar.
then inside the page, there are a few links, i want, when clicking a link, a new
window opens, but still without tool bar, address bar and status bar.
My code can open the first new window properly, but it cannot open the second
one at all. Could anyone please help me?

function popOpen(url,name,attributes) {
windowHandle = window.open(escape(url),name,scrollbars = 1,"'left=20,top=20");
}
 
W

web.dev

Hi Yaqian,

Does the url of the second page also have function popOpen so that you
can open a second page?
If yes, then did you check to see that the function is called
correctly?
 
G

Grant Wagner

Yaqian said:
Hi, I want to open a new window without tool bar, address bar and
status bar.
then inside the page, there are a few links, i want, when clicking a
link, a new
window opens, but still without tool bar, address bar and status bar.
My code can open the first new window properly, but it cannot open the
second
one at all. Could anyone please help me?

function popOpen(url,name,attributes) {
windowHandle = window.open(escape(url),name,scrollbars =
1,"'left=20,top=20");
}

The third parameter of window.open() is a comma-separated string of
attributes:

window.open(url, name, "scrollbars=1,left=20,top=20");

You do not need to, nor should you, escape the URL... if there is query
string content that needs to be URI encoded, that should be done before
passing the url to your popOpen() function, or pass the query string
name/value pairs as object property/values so you can escape (not really
encodeURI(), but it will have to do if you want to support user agents
which don't support encodeURI()) each query value as it is appended to
the url:

function popOpen(url, queryPairs, name, attributes) {
var queryString = [];
for (var queryPair in queryPairs) {
// escape() could be encodeURI() if you
// can guarantee it will be available
queryString.push(queryPair + '=' +
escape(queryPairs[queryPair]);
}
w = window.open(
url + (queryString.length > 0 ? '?' + queryString.join('&')
: ''),
name,
attributes
);
}
 
G

Gérard Talbot

Grant Wagner a écrit :
Hi, I want to open a new window without tool bar, address bar and
status bar.
then inside the page, there are a few links, i want, when clicking a
link, a new
window opens, but still without tool bar, address bar and status bar.
My code can open the first new window properly, but it cannot open the
second
one at all. Could anyone please help me?

function popOpen(url,name,attributes) {
windowHandle = window.open(escape(url),name,scrollbars =
1,"'left=20,top=20");
}


The third parameter of window.open() is a comma-separated string of
attributes:

window.open(url, name, "scrollbars=1,left=20,top=20");

You do not need to, nor should you, escape the URL... if there is query
string content that needs to be URI encoded, that should be done before
passing the url to your popOpen() function, or pass the query string
name/value pairs as object property/values so you can escape (not really
encodeURI(), but it will have to do if you want to support user agents
which don't support encodeURI()) each query value as it is appended to
the url:

function popOpen(url, queryPairs, name, attributes) {
var queryString = [];
for (var queryPair in queryPairs) {
// escape() could be encodeURI() if you
// can guarantee it will be available
queryString.push(queryPair + '=' +
escape(queryPairs[queryPair]);
}
w = window.open(
url + (queryString.length > 0 ? '?' + queryString.join('&')

Shouldn't that be '&' instead of '&'?
Just asking.
: ''),
name,
attributes
);
}

Gérard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top