By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,380 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,380 IT Pros & Developers. It's quick & easy.

Open page in new window, but add some text

P: n/a
Hi all.
I have a (hopefully) pretty simple question.
I open a link in a new window:

<a href="http://www.somewhere.com/some.hml"
onclick="window.open(url,null,'resizable=yes,toolb ar=no,location=no,directories=no,status=no,menubar =no,scrollbars=yes,width=600,height=400');">Link</a>
The page I am opening is not mine.
I want to edit the content of the page I am opening, adding text
"This page is opened in a new window" as a first thing after the body
tag of the opened page.

Is it possible to do it with javascript, while opening the page, or
should I use Java?

Thank you very much for help.

Anna
Jul 20 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Anna wrote on 15 jul 2003 in comp.lang.javascript:
I open a link in a new window:

<a href="http://www.somewhere.com/some.hml"
onclick="window.open(url,null,'resizable=yes,toolb ar=no,location=no,dir
ectories=no,status=no,menubar=no,scrollbars=yes,wi dth=600,height=400');
">Link</a> The page I am opening is not mine.
I want to edit the content of the page I am opening, adding text
"This page is opened in a new window" as a first thing after the body
tag of the opened page.

Is it possible to do it with javascript, while opening the page, or
should I use Java?


It is not your page, so security forbids you to alter it.

You could data-mine the page serverside and
use the parts to make a new page, however.

I do not know where your Java should come in though.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2

P: n/a
Thanks for answering.

I don't really want to change the actual page.
What I was thinking, is maybe copy all the contents of the page, edit
it, and present the edited content in a new browser window. That way I
will not need to edit the page serverside. But this cannot probably be
done with javascript, I am using now JSP+Java.
I just thought, that maybe some possibility o fthis could exist in
javascript - would be much simpler.

Thanks for help anyway

Anna

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3

P: n/a
Anna Afonchenko wrote:
Thanks for answering.

I don't really want to change the actual page.
What I was thinking, is maybe copy all the contents of the page, edit
it, and present the edited content in a new browser window. That way I
will not need to edit the page serverside. But this cannot probably be
done with javascript, I am using now JSP+Java.
I just thought, that maybe some possibility o fthis could exist in
javascript - would be much simpler.

Thanks for help anyway

Anna


Client-side JavaScript in the default security environment can only read
content from the same domain it was downloaded from. That is, the XML HTTP
Request object and all the iframe "tricks" to read/parse HTML pages only
work if you want data from a page on your own site.

For retrieving data from another host, the best solution is server-side,
where you control the technology and can guarantee the user will see what
you intended them to see.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #4

P: n/a
DU
DU wrote:
Anna wrote:
Hi all.
I have a (hopefully) pretty simple question.
I open a link in a new window:

<a href="http://www.somewhere.com/some.hml"
onclick="window.open(url,null,'resizable=yes,toolb ar=no,location=no,directories=no,status=no,menubar =no,scrollbars=yes,width=600,height=400');">Link</a>

<a href="http://www.somewhere.com/some.html" target="RequestedPopup"
onclick="window.open(this.href, this.target,
'resizable=yes,status=yes,scrollbars=yes,width=600 ,height=400');"
title="Clicking this link will open a new window (popup) or will re-use
an already opened one">Link <img
src="http://www.brinkster.com/doctorunclear/GRAPHICS/PNG/OpenRequestedPopup.png"
class="RequestedPopup" title="Clicking the link will create a new window
(popup) or will re-use an already opened one" alt="Clicking the link
will create a new window (popup) or will re-use an already opened one"></a>


The Top Ten New Mistakes of Web Design
3. Non-Standard Use of GUI Widgets
"Interaction consistency is an additional reason it's wrong to open new
browser windows: the standard result of clicking a link is that the
destination page replaces the origination page in the same browser
window. Anything else is a violation of the users' expectations and
makes them feel insecure in their mastery of the Web."
http://www.useit.com/alertbox/990530.html
J. Nielsen

but he offers a way to compensate this "consistency violation" accordingly

Ten Good Deeds in Web Design
"8. Use link titles to provide users with a preview of where each link
will take them, before they have clicked on it."
http://www.useit.com/alertbox/991003.html

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/

Jul 20 '05 #5

P: n/a
DU
DU wrote:

I forgot the importantissimo return false in both my posts. Sorry.

<a href="http://www.somewhere.com/some.html" target="RequestedPopup"
onclick="window.open(this.href, this.target,
'resizable=yes,status=yes,scrollbars=yes,width=600 ,height=400');
return false;

" title="Clicking this link will open a new window (popup) or will re-use
an already opened one">Link <img
src="http://www.brinkster.com/doctorunclear/GRAPHICS/PNG/OpenRequestedPopup.png"
class="RequestedPopup" title="Clicking the link will create a new window
(popup) or will re-use an already opened one" alt="Clicking the link
will create a new window (popup) or will re-use an already opened one"></a>


and while I'm at it, your "link" text is certainly not recommendable. J.
Nielsen again on this:

7. Begin Link Names with the Most Important Keyword
"Links are the action items on a homepage, and when you start each link
with a relevant word, you make it easier for scanning eyes to
differentiate it from other links on the page."
http://www.useit.com/alertbox/20020512.html

So, "link", "click me", "click here", "ok", "go", "image", etc.. are all
not recommendable ways of editing a link. But "My garden", "My dog", "My
resume", etc.. are all good ways of editing links.

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/

Jul 20 '05 #6

P: n/a
DU
Evertjan. wrote:
Anna wrote on 15 jul 2003 in comp.lang.javascript:
I open a link in a new window:

<a href="http://www.somewhere.com/some.hml"
onclick="window.open(url,null,'resizable=yes,too lbar=no,location=no,dir
ectories=no,status=no,menubar=no,scrollbars=yes, width=600,height=400');
">Link</a> The page I am opening is not mine.
I want to edit the content of the page I am opening, adding text
"This page is opened in a new window" as a first thing after the body
tag of the opened page.

Is it possible to do it with javascript, while opening the page, or
should I use Java?

It is not your page, so security forbids you to alter it.

You could data-mine the page serverside and
use the parts to make a new page, however.

I do not know where your Java should come in though.


I'm sure Anna misworded and mis-presented her issue, question. I'm
convinced the question, interest she meant to ask is excellent though.

Here's a page where I modify a popup window's content with only DOM
methods on a resource which is not on my domain name server (see the
Olivia Newton-John link):

Create a sub-window and dynamically DOM-insert an image:
http://www10.brinkster.com/doctorunc...geInPopup.html

DU
---------------------------
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/

Jul 20 '05 #7

P: n/a
DU
DU wrote:

The Top Ten New Mistakes of Web Design
3. Non-Standard Use of GUI Widgets
"Interaction consistency is an additional reason it's wrong to open new
browser windows: the standard result of clicking a link is that the
destination page replaces the origination page in the same browser
window. Anything else is a violation of the users' expectations and
makes them feel insecure in their mastery of the Web."
http://www.useit.com/alertbox/990530.html
J. Nielsen

but he offers a way to compensate this "consistency violation" accordingly

Ten Good Deeds in Web Design
"8. Use link titles to provide users with a preview of where each link
will take them, before they have clicked on it."
http://www.useit.com/alertbox/991003.html


"Until user agents allow users to turn off spawned windows, do not cause
pop-ups or other windows to appear and do not change the current window
*_without informing the user_*.
(...)if your link spawns a new window, or causes another windows to "pop
up" on your display, or move the focus of the system to a new FRAME or
Window, then the nice thing to do is to tell the user that something
like that will happen."
W3C Web Accessibility Initiative Checkpoint 10.1
http://www.w3.org/WAI/wcag-curric/sam77-0.htm
DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/

Jul 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.