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

aPossible to Make A "Dummy" Anchor Tag **without** Jumping Back Up???

P: n/a
Hi, People,

Is it possible to have an "empty" or "dummy" <a href***without***
the browser jumping back up the page??

I have a hyperlink that doesn't point to another document, but is used
to call forth a modal window onClick (or is there another way, without
text or image links, of calling forth JavaScript on user activity??).
I would like to spare my visitors the inconvenience and visually
jarring effect of getting thrown back up to the top of the page! =(
Jun 27 '08 #1
Share this Question
Share on Google+
20 Replies


P: n/a
Prisoner at War schrieb:
Hi, People,

Is it possible to have an "empty" or "dummy" <a href***without***
the browser jumping back up the page??

I have a hyperlink that doesn't point to another document, but is used
to call forth a modal window onClick (or is there another way, without
text or image links, of calling forth JavaScript on user activity??).
I would like to spare my visitors the inconvenience and visually
jarring effect of getting thrown back up to the top of the page! =(
Click listeners can be attached to practically *all* elements of a
document. No need for an anchor. And no need for crossposting into all
sorts of groups.

x'posts removed.

Gregor
Jun 27 '08 #2

P: n/a

Ah, well, using "javascript:;" for a value did the trick! The browser
no longer throws the viewer back up to the top of the page.

Unfortunately, that modal window doesn't center vertically, so *it* is
still up at the top of the page!

How can I center an element *vertically*, please?

It's just a box, actually, and I know that with CSS "auto" centers it
horizontally -- but what about vertically??
Jun 27 '08 #3

P: n/a
On 05/01/08 04:16 pm, Prisoner at War wrote:
>
Is it possible to have an "empty" or "dummy" <a href***without***
the browser jumping back up the page??

I have a hyperlink that doesn't point to another document, but is used
to call forth a modal window onClick (or is there another way, without
text or image links, of calling forth JavaScript on user activity??).
You can use the onClick attribute with just about any element. It soes
not have to be an anchor.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Jun 27 '08 #4

P: n/a
In article
<19**********************************@m45g2000hsb. googlegroups.com>,
Prisoner at War <pr*************@yahoo.comwrote:
Ah, well, using "javascript:;" for a value did the trick! The browser
no longer throws the viewer back up to the top of the page.

Unfortunately, that modal window doesn't center vertically, so *it* is
still up at the top of the page!

How can I center an element *vertically*, please?

It's just a box, actually, and I know that with CSS "auto" centers it
horizontally -- but what about vertically??
Looked at

<http://www.jakpsatweb.cz/css/css-vertical-center-solution.html>

?

--
dorayme
Jun 27 '08 #5

P: n/a
Dan
On May 1, 7:16 pm, Prisoner at War <prisoner_at_...@yahoo.comwrote:
Hi, People,

Is it possible to have an "empty" or "dummy" <a href***without***
the browser jumping back up the page??
End the JavaScript with "return false;" and that will suppress the
jump to the normal href destination.

It's then a good idea to make the href value a URL to a separate page
with the same content as the attempted popup, so as to make that
content accessible to non-JavaScript users.

--
Dan
Jun 27 '08 #6

P: n/a
On May 1, 7:16*pm, Prisoner at War <prisoner_at_...@yahoo.comwrote:
Hi, People,

Is it possible to have an "empty" or "dummy" <a href***without***
the browser jumping back up the page??

I have a hyperlink that doesn't point to another document, but is used
to call forth a modal window onClick (or is there another way, without
text or image links, of calling forth JavaScript on user activity??).
I would like to spare my visitors the inconvenience and visually
jarring effect of getting thrown back up to the top of the page! *=(
Try using <a href="#" onclick=" . . . ;return false">

Herbert
Jun 27 '08 #7

P: n/a
[Note: follow-up to comp.lang.javascript]

Thu, 1 May 2008 16:16:49 -0700 (PDT), /Prisoner at War/:
Is it possible to have an "empty" or "dummy" <a href***without***
the browser jumping back up the page??

I have a hyperlink that doesn't point to another document, but is used
to call forth a modal window onClick (or is there another way, without
text or image links, of calling forth JavaScript on user activity??).
I would like to spare my visitors the inconvenience and visually
jarring effect of getting thrown back up to the top of the page! =(
If the element is not really a hyper link why marking it as such?
Better use generic SPAN element or A(nchor) element without 'href'
and attach 'click' handler to it. This will spare your visitors the
confusion with encountering hyper links which are not really hyper
links.

Apart from that from the incorrect hyper link usage note, you could
always return false in the 'click' handler to prevent the browser
from doing its default action - to follow the link:

<script type="text/javascript">
function openWindow(url, name, features) {
if (open) {
var n = (name) ? name : "_blank";
var f = (features) ? features : "resizable,scrollbars";
var win = open(url, n, f);
if (win) {
return false;
}
}
return true;
}
</script>

<a href="http://www.w3.org/"
onclick="return openWindow(this.href);">W3C</a>

--
Stanimir
Jun 27 '08 #8

P: n/a
Stanimir Stamenkov wrote:
Thu, 1 May 2008 16:16:49 -0700 (PDT), /Prisoner at War/:
>I have a hyperlink that doesn't point to another document, but is used
to call forth a modal window onClick (or is there another way, without
text or image links, of calling forth JavaScript on user activity??).
I would like to spare my visitors the inconvenience and visually
jarring effect of getting thrown back up to the top of the page! =(

If the element is not really a hyper link why marking it as such?
Better use generic SPAN element or A(nchor) element without 'href'
and attach 'click' handler to it. This will spare your visitors the
confusion with encountering hyper links which are not really hyper
links.
However, this reasoning is flawed because the confusion of the user about
what looks like a control that does not appear to work remains.
Apart from that from the incorrect hyper link usage note, you could
always return false in the 'click' handler to prevent the browser
from doing its default action - to follow the link:
Not always, but only if and when appropriate (but your example at least
makes that clear).
<script type="text/javascript">
function openWindow(url, name, features) {
if (open) {
This is pointless. If no object in the scope chain has an `open' property,
this will result in a ReferenceError runtime exception, and it will cause
the script to break if unhandled.

Furthermore, that an object has a property does not necessarily mean that
this property can be called. Consider this instead:

function isMethod(o, p)
{
if (typeof o == "string")
{
o = (typeof this[o] != "undefined" && this[o]);
}

return o && /\s*(function|object|unknown)\s*/i.test(typeof o[p])
&& o[p];
}

function openWindow(url, name, features)
{
if (isMethod("window", "open"))
{
var n = (name) ? name : "_blank";
The parentheses are unnecessary here. If you use parentheses here, then I
suggest

var n = (name ? name : "_blank");

But the operation is inefficient anyway. Consider this instead:

if (!name) name = "_blank";

But `_blank' is a reserved name, it should not be used this way. Better
choose a different, distinct name so that the window can be reused and the
desktop of the user is not cluttered up with windows if the element is
activated more than one time.

if (!name) name = "popup42";
var f = (features) ? features : "resizable,scrollbars";
if (!features) features = "resizable,scrollbars";
var win = open(url, n, f);
Other objects in the scope chain may have an open() method, too, and you
would want to avoid calling that.

var win = window.open(url, name, features);
if (win) {
return false;
}
}
return true;
This can be simplified to:

return !win;
}
</script>

<a href="http://www.w3.org/"
onclick="return openWindow(this.href);">W3C</a>

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Jun 27 '08 #9

P: n/a
On May 1, 8:19 pm, dorayme <doraymeRidT...@optusnet.com.auwrote:
>

Looked at

<http://www.jakpsatweb.cz/css/css-vertical-center-solution.html>

?

--
dorayme

Hmmm!! Looks interesting!

Thanks, this just might be the ticket! I'll have to give it a shot --
but it looks like it will work! (At least I can understand the
example in theory!)
Jun 27 '08 #10

P: n/a
On May 1, 8:26 pm, Dan <d...@tobias.namewrote:
>

End the JavaScript with "return false;" and that will suppress the
jump to the normal href destination.
Good grief! I'd totally forgotten that!!

Yes, it says just so in Chapter 4, Rollover Buttons, of "The Book of
JavaScript, Second Edition!" Damn, in one ear, out the other....
It's then a good idea to make the href value a URL to a separate page
with the same content as the attempted popup, so as to make that
content accessible to non-JavaScript users.
Actually, the href doesn't point to a document, but to text that's
invisible until invoked by an onClick, creating that modal window.

God, what a dilemma! Just what in heck am I supposed to do about
those people (like me!) whose IE7 disabled ActiveX Controls??
--
Dan
Jun 27 '08 #11

P: n/a
On May 1, 8:26 pm, Herbert Blenner <a1ea...@verizon.netwrote:
>

Try using <a href="#" onclick=" . . . ;return false">

Herbert
Many thanks -- for the reminder! Can't believe I forgot that one....
Jun 27 '08 #12

P: n/a
On 01 May 2008, Prisoner at War <pr*************@yahoo.comwrote:
I have a hyperlink that doesn't point to another document, but is used
to call forth a modal window onClick (or is there another way, without
text or image links, of calling forth JavaScript on user activity??).
Sure. onmouseover, onmouseout, onsubmit, etc., etc.
I would like to spare my visitors the inconvenience and visually
jarring effect of getting thrown back up to the top of the page! =(
--
Neredbojias
http://www.neredbojias.net/
Great sights and sounds
Jun 27 '08 #13

P: n/a

Say, just as an update: it turns out that I was able to achieve
vertical alignment by simply using the position:fixed property and
value, in conjunction with margin:23% (it was originally margin:
400px)....

I may have lucked out, though, as I'm not sure exactly how it's
working in the code I've got (below)...also rather bummed that Sam
Collison's good if dry CSS book didn't discuss the vertical-align
property at all despite listing it in the appendix!
#overlay div
{
width:300px;
margin: 23% auto;
background-color: #fff;
border:1px dashed #000;
padding:15px;
text-align:center;
position:fixed;
left: 38%;
}
Jun 27 '08 #14

P: n/a

Ackk!!

That position:fixed property and value has an odd visual artifact in
Firefox 2! (It has a different one in Opera 9!)

The modal window that's "on" the page is invisible until turned on by
a function that's called onClick -- except when scrolling the webpage,
without having clicked on the hyperlink that calls the function: text
scrolling past that invisible modal window "drags by" in the form of
that modal window! It's like when in the Schwarzenegger movie
"Predator" the alien goes invisible, but you can still see the vague
"shimmer" of its outline, especially when it moves....

In Opera 9, position:fixed causes the bottom half of the text in the
modal window to not display if that modal window pops up below "the
fold" (the halfway scroll-point of a webpage)!

Can somebody tell me what's the matter with all this?? Some kind of
inheritance bugaboo??

#overlay div
{
width:300px;
margin: 23% auto;
background-color: #fff;
border:1px dashed #000;
padding:15px;
text-align:center;
position:fixed;
left: 38%;
}
Jun 27 '08 #15

P: n/a
Scripsit Prisoner at War:
Hi, People,
People just left after noticing your pointless crossposting without even
setting followups and your continued violation of netiquette when you
comment without quoting what you are responding to. Stay tuned to
getting ignored in future unless you learn some habits.
Is it possible to have an "empty" or "dummy" <a href***without***
the browser jumping back up the page??
Yes, <a href="#foo" name="foo">. But why would you do that? It's 100.1%
certain that you don't understand what your real problem is and that you
are consequently creating new problems.
I have a hyperlink that doesn't point to another document, but is used
to call forth a modal window onClick
So what made you use a link when you don't want to link?
(or is there another way, without
text or image links, of calling forth JavaScript on user activity??).
Yes of course. Read any introduction to basics of the elements of using
client-side scripting on www pages. Make sure it's a modern one that
discusses the problem "how do I create the <input type="button"element
dynamically so that it does not appear when it does not work, i.e. when
scripting is disabled?".
I would like to spare my visitors the inconvenience and visually
jarring effect of getting thrown back up to the top of the page! =(
Spare them the nasty effects of creating new windows for them.

Followups set to alt.html.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Jun 27 '08 #16

P: n/a
On May 2, 1:52 am, "Jukka K. Korpela" <jkorp...@cs.tut.fiwrote:
>

People just left after noticing your pointless crossposting without even
setting followups and your continued violation of netiquette when you
comment without quoting what you are responding to. Stay tuned to
getting ignored in future unless you learn some habits.
I don't understand what you mean. How's the cross-posting pointless?
I'm working on my site, which involves CSS and JavaScript in addition
to HTML and general design issues.
Yes, <a href="#foo" name="foo">.
Hmmm, using a name or id attribute stops the browser from trying to
follow the href the way a "javascript:;" or "return false;" does?
Interesting!
But why would you do that?
"
I have a hyperlink that doesn't point to another document, but is used
to call forth a modal window onClick (or is there another way, without
text or image links, of calling forth JavaScript on user activity??).
I would like to spare my visitors the inconvenience and visually
jarring effect of getting thrown back up to the top of the page! =(

"
It's 100.1%
certain that you don't understand what your real problem is and that you
are consequently creating new problems.
Very possible. That's why I'm asking around!
So what made you use a link when you don't want to link?
Well, the user has to have a way of calling forth information in that
modal window. (And no I really do want that information in a modal
window instead of "cluttering" up the rest of my paragraph.)
Yes of course. Read any introduction to basics of the elements of using
client-side scripting on www pages. Make sure it's a modern one that
discusses the problem "how do I create the <input type="button"element
dynamically so that it does not appear when it does not work, i.e. when
scripting is disabled?".
Hmm, an input button! I would need it very small, though...I'm using
a modal window like a footnote, see, or an endnote...I wonder if I can
style that button to be visually minuscule....
Spare them the nasty effects of creating new windows for them.
But that's the thing -- I don't want a webpage full of footnotes, or
redirect the user to another page full of endnotes. A modal window is
the only way I can think of where somewhat extraneous information can
still be offered...unless...I use some kind of "thought balloon"??
Hey, can I do them Ajax-style onMouseOver balloons with *JavaScript*??
Followups set to alt.html.
Why? The topic of modal windows and how to best implement them seems
relevant to all the newsgroups I'd chosen.
--
Jukka K. Korpela ("Yucca")http://www.cs.tut.fi/~jkorpela/
I hate yucca...it's cactus -- helpful for thirst in the desert I
suppose but not a good-tasting plant to cook with!
Jun 27 '08 #17

P: n/a
Followup-To: comp.infosystems.www.authoring.html

On 02.5.2008 г. 04:21, /Thomas 'PointedEars' Lahn/:
Stanimir Stamenkov wrote:
>Thu, 1 May 2008 16:16:49 -0700 (PDT), /Prisoner at War/:
>>I have a hyperlink that doesn't point to another document, but is used
to call forth a modal window onClick (or is there another way, without
text or image links, of calling forth JavaScript on user activity??).
I would like to spare my visitors the inconvenience and visually
jarring effect of getting thrown back up to the top of the page! =(

If the element is not really a hyper link why marking it as such?
Better use generic SPAN element or A(nchor) element without 'href'
and attach 'click' handler to it. This will spare your visitors the
confusion with encountering hyper links which are not really hyper
links.

However, this reasoning is flawed because the confusion of the user about
what looks like a control that does not appear to work remains.
I agree HTML Form controls (non-submit buttons) should be used
whenever possible, but as far as I know people avoid them because
they are "harder" to style (they are replaced elements the styling
of which is non-standardized, currently). Styling is the main
reason people abuse hyper links instead of using standard form buttons.

Scripting is used to implement non-standard UI controls, too. The
Google Maps map, for instance. It can't be "expressed" using
standard form controls and it can't possibly work without full
scripting and styling support. In this regard I think it is better
to style a SPAN like a button (or whatever is appropriate) and
attach a custom script action to it, rather than abusing a hyper
link element for that purpose.

--
Stanimir
Jun 27 '08 #18

P: n/a
Fri, 02 May 2008 03:21:52 +0200, /Thomas 'PointedEars' Lahn/:
Stanimir Stamenkov wrote:
> <script type="text/javascript">
function openWindow(url, name, features) {
if (open) {

This is pointless. If no object in the scope chain has an `open' property,
this will result in a ReferenceError runtime exception, and it will cause
the script to break if unhandled.

Furthermore, that an object has a property does not necessarily mean that
this property can be called.
I acknowledge JavaScript is not my area of expertise and I lack many
details of the language. I've initially written it as:

if (typeof open == 'function') {
...

But then tried IE (6 at least) says the typeof (window.open) is
'object' rather than a 'function' - is this o.k.?

I still suspect my initial code could cause the run-time error you
point. Is the next one better?

if (typeof window['open'] == 'function') {
...

--
Stanimir
Jun 27 '08 #19

P: n/a
Stanimir Stamenkov wrote:
Fri, 02 May 2008 03:21:52 +0200, /Thomas 'PointedEars' Lahn/:
>Stanimir Stamenkov wrote:
>> <script type="text/javascript">
function openWindow(url, name, features) {
if (open) {
This is pointless. If no object in the scope chain has an `open' property,
this will result in a ReferenceError runtime exception, and it will cause
the script to break if unhandled.

Furthermore, that an object has a property does not necessarily mean that
this property can be called.

I acknowledge JavaScript is not my area of expertise and I lack many
details of the language. I've initially written it as:

if (typeof open == 'function') {
...

But then tried IE (6 at least) says the typeof (window.open) is
'object' rather than a 'function' - is this o.k.?
Yes, it is. Since this property is likely to refer to a host object, the
`typeof' operation applied to it may result in any string value (see
ECMA-262 Ed. 3 Final, section 11.4.3). IIUC, it has been established here
that the operation results either in "object" or "unknown" for callable host
objects in the MSHTML DOM (CMIIW). Hence the isMethod() method that I
posted before. (Other subscribers have devised their own methods for
feature detection, search the archives.)
I still suspect my initial code could cause the run-time error you
point. Is the next one better?

if (typeof window['open'] == 'function') {
...
(Please understand that

if (typeof window.open == 'function') {

is equivalent to your code.)

If we assume that an object in the scope chain has a `window' property,
which can be observed with many HTML UAs but nevertheless is nothing that
can be relied on (YMMV), then this is not likely to cause an error.

But it will still fail to detect the availability of the window.open()
method in the MSHTML DOM. I suggested you use isMethod() instead.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Jun 27 '08 #20

P: n/a
On May 2, 12:51 pm, Jim Moe <jmm-list.AXSPA...@sohnen-moe.comwrote:
>

I guess I don't get it then. You need a link that's not a link but looks
like a link and does non-link things. I can see why you are having difficulty.
Use a <span>, give it a class that makes it look like a link (to confuse
everyone), and the onClick attribute to do the non-link things.
I suppose I'm not making myself clear (or maybe I really don't know
what I'm trying to do!)...instead of footnotes on every page, I
figured I'd present such information as an option. That means a
button or a link, right?

So clicking a link -- say, an asterisk -- brings up a modal window.
That way, the page itself is not cluttered by extraneous info but the
user has the option of viewing it.

I could use a button, but unless buttons can be made as small as an
asterisk, I think a hyperlink is what I have to use.

Or is there anything else other than a hyperlink or button?

In the meantime, I'm considering onMouseOver "help balloons" instead,
instead of onClick modal windows. Help balloons seem less intrusive
and in-your-face than modal windows.

Any more advice much appreciated.
--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Jun 27 '08 #21

This discussion thread is closed

Replies have been disabled for this discussion.