Opening Link in a frame

E

Eustace

I have a webpage with 2 frames (sidebar, content). The link is in the
content frame.

How can I make a link open in the whole window?

If I use

<a href="http://www.link.html" onclick="window.open (this.href,
'content'); return false">Link</a>

it will of course open in the content frame. I do not want this.

If I use

<a href="http://www.link.html" onclick="window.open (this.href, '');
return false">Link</a>

clicking will open another browser window or tab. That's better, but not
exactly what I want.

I want I make the link open in the same window, not inside the content
frame or in another window. How do I do this?

Thanks,

emf
 
T

Thomas 'PointedEars' Lahn

Scott said:

Since they have asked here, it might be better to point out that whenever
there is no Window instance with the specified name (i.e. no `name'
property value of a Window object equals that of the second argument of
window.open()), a new Window is supposed to be created, and that a new tab
instead of a new window is less likely to be opened if the dimensions of
the window have been provided. Therefore,

window.open("...", "w" + (new Date()).getTime(),
"width=" + Math.min(640, screen.availWidth)
+ ",height=" + Math.min(480, screen.availHeight)
+ ",menubar,toolbar,location,directories,status"
+ ",resizable,scrollbars,titlebar,toolbars");

could provide what the OP is looking for, while that is less likely with
the `target' attribute. However one should fully understand and weigh the
the consequences of such a call as described in e.g.
<https://developer.mozilla.org/En/DOM/Window.open>.


PointedEars
 
E

Evertjan.

Eustace wrote on 02 mrt 2010 in comp.lang.javascript:
I have a webpage with 2 frames (sidebar, content). The link is in the
content frame.

How can I make a link open in the whole window?

If I use

<a href="http://www.link.html" onclick="window.open (this.href,
'content'); return false">Link</a>

"window.open( this.href , '_top', '');return false;"
 
E

Eustace

Eustace wrote on 02 mrt 2010 in comp.lang.javascript:


"window.open( this.href , '_top', '');return false;"

Thanks a lot. I had googled for an answer before posting but had not
come close to finding the answer.

emf
 
T

Thomas 'PointedEars' Lahn

Eustace said:
Eustace wrote on 02 mrt 2010 in comp.lang.javascript:
I have a webpage with 2 frames (sidebar, content). The link is in the
content frame.

How can I make a link open in the whole window?
[...]
<a href="http://www.link.html" onclick="window.open (this.href,
'content'); return false">Link</a>

"window.open( this.href , '_top', '');return false;"

Thanks a lot. I had googled for an answer before posting but had not
come close to finding the answer.

If the suggested solution suffices, you should use

<a href="..." target="_top" ...>...</a>

instead of scripting, so that it works everywhere.


PointedEars
 
E

Evertjan.

Thomas 'PointedEars' Lahn wrote on 03 mrt 2010 in comp.lang.javascript:
Eustace said:
Eustace wrote on 02 mrt 2010 in comp.lang.javascript:
I have a webpage with 2 frames (sidebar, content). The link is in
the content frame.

How can I make a link open in the whole window?
[...]
<a href="http://www.link.html" onclick="window.open (this.href,
'content'); return false">Link</a>

"window.open( this.href , '_top', '');return false;"

Thanks a lot. I had googled for an answer before posting but had not
come close to finding the answer.

If the suggested solution suffices, you should use

<a href="..." target="_top" ...>...</a>

instead of scripting, so that it works everywhere.

Incorrect, Thomas,
in the example maybe, but the JS answer is more than that.

Try:

<a
href = "..."
target = "_top"
onclick =
"if (prompt('OK?')) window.open(this.href ,'_top',''); return false;"
Go to the top!</a>

this will gracefully, but without the prompting question,
default to the action if JS is absent.
 
D

David Mark

Evertjan. said:
Thomas 'PointedEars' Lahn wrote on 03 mrt 2010 in comp.lang.javascript:
Eustace said:
On 2010-03-02 18:22 Evertjan. wrote:
Eustace wrote on 02 mrt 2010 in comp.lang.javascript:
I have a webpage with 2 frames (sidebar, content). The link is in
the content frame.

How can I make a link open in the whole window?
[...]
<a href="http://www.link.html" onclick="window.open (this.href,
'content'); return false">Link</a>
"window.open( this.href , '_top', '');return false;"
Thanks a lot. I had googled for an answer before posting but had not
come close to finding the answer.
If the suggested solution suffices, you should use

<a href="..." target="_top" ...>...</a>

instead of scripting, so that it works everywhere.

Incorrect, Thomas,
in the example maybe, but the JS answer is more than that.

Try:

<a
href = "..."
target = "_top"
onclick =
"if (prompt('OK?')) window.open(this.href ,'_top',''); return false;"
Go to the top!</a>

this will gracefully, but without the prompting question,
default to the action if JS is absent.

But it won't do very well if the window.open call fails to open a new
window (or tab). You must check the return value of that method before
determining whether to return false (which cancels the default action).
I don't see what the prompt is for either. Is what OK?
 
D

Dr J R Stockton

Wed said:

Since it does not offer Week-Numbering Dates, Ordinal Dates, the Date of
Easter, or the dates in any non-Gregorian calendar, ISTM that the claim
of "all-purpose" is considerably exaggerated.

The code in datecalc.js nowhere uses "new" : it takes no advantage of
the JavaScript Date Object, and could have been converted from some
simpler language.

The name "julianDate" is semantically incorrect; you should use
"ordinalDate". Don't copy IBM.

function isValid(yyyy, mm, dd) can more briefly be done with a Date
Object, as often discussed here in the past.

function absoluteDate(yyyy, mm, dd) can more briefly be done with a
Date Object, using new Date(Date.UTC(yyyy, mm, dd)) .

function gregorianDate(absDate) can more briefly be done with a Date
Object, using UTC.

<https://files.nyu.edu/emf202/public/js/datecalc.js> may be damaged ;
the last visible character in it is apparently '{'

The newsgroup FAQ used to have something helpful about general date/time
coding in JavaScript.

I suggest that you change your signature.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
 
E

Evertjan.

David Mark wrote on 04 mrt 2010 in comp.lang.javascript:
But it won't do very well if the window.open call fails to open a new
window (or tab).

'_top' will/should not open a new window or tap.
You must check the return value of that method before
determining whether to return false (which cancels the default action).

You could but not must.
I don't see what the prompt is for either. Is what OK?

This was an example of coding, not of practical usefullness.
 
E

Eustace

Since it does not offer Week-Numbering Dates, Ordinal Dates, the Date of
Easter, or the dates in any non-Gregorian calendar, ISTM that the claim
of "all-purpose" is considerably exaggerated.

All-purpose only implies being able to be used in languages where a Date
Object or whenever it is for whatever reason undesirable.
The code in datecalc.js nowhere uses "new" : it takes no advantage of
the JavaScript Date Object, and could have been converted from some
simpler language.

The name "julianDate" is semantically incorrect; you should use
"ordinalDate". Don't copy IBM.

It was suggested to me by my mentor (after I had taken a 1 credit class
in Basic at a Community College many years ago). Since then I have
become aware that it was not accurate... Now I know where he got it from.
function isValid(yyyy, mm, dd) can more briefly be done with a Date
Object, as often discussed here in the past.

function absoluteDate(yyyy, mm, dd) can more briefly be done with a
Date Object, using new Date(Date.UTC(yyyy, mm, dd)) .

function gregorianDate(absDate) can more briefly be done with a Date
Object, using UTC.

<https://files.nyu.edu/emf202/public/js/datecalc.js> may be damaged ;
the last visible character in it is apparently '{'

I am grateful for the observation.
The newsgroup FAQ used to have something helpful about general date/time
coding in JavaScript.

I suggest that you change your signature.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

I still find my functions a simpler alternative for general purposes
when hours etc. are not involved.

emf
 

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,774
Messages
2,569,596
Members
45,141
Latest member
BlissKeto
Top