473,396 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Prevent reload (redux)

I'm a j-script (and html) newbie with what I thought was a simple
requirement:

1) From a link in a primary window open a secondary window
2) Want to specify size of secondary window
3) Want primary window NOT to reload when secondary opens

Don't want to prejudge the approach; I'm guessing Javascript can help,
and in fact have accomplished 1) and 2) above with the following,
embedded in the body of the primary window html:

<a href="javascript:location='primary_window.html';
window.open('secondary_window.html', 'secondary_window_label',
'height=345,width=550')">link_text</a>

But when the secondary window opens, the primary window reloads. I've
seen earlier posts addressing this problem (or similar ones), but I
haven't been able to make any of the suggestions work. Any guidance
much appreciated.

Dec 4 '05 #1
5 3872
skydanb said the following on 12/4/2005 1:46 PM:
I'm a j-script (and html) newbie with what I thought was a simple
requirement:

1) From a link in a primary window open a secondary window
2) Want to specify size of secondary window
3) Want primary window NOT to reload when secondary opens

Don't want to prejudge the approach; I'm guessing Javascript can help,
and in fact have accomplished 1) and 2) above with the following,
embedded in the body of the primary window html:

<a href="javascript:location='primary_window.html';
window.open('secondary_window.html', 'secondary_window_label',
'height=345,width=550')">link_text</a>

But when the secondary window opens, the primary window reloads.
Thats because you are telling it to in the href attribute.
And don't use javascript: hrefs. It's in the FAQ.
I've seen earlier posts addressing this problem (or similar ones), but I
haven't been able to make any of the suggestions work. Any guidance
much appreciated.


And you didn't find this solution?

<a href="secondary_window.html" target="secondary_window_label"
onclick="window.open(this.href,this.target,'attrib utes here')">
link_text</a>
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 4 '05 #2
skydanb wrote:
1) From a link in a primary window open a secondary window
2) Want to specify size of secondary window
3) Want primary window NOT to reload when secondary opens

Don't want to prejudge the approach; I'm guessing Javascript can help,
and in fact have accomplished 1) and 2) above with the following,
embedded in the body of the primary window html:

<a href="javascript:location='primary_window.html';
window.open('secondary_window.html', 'secondary_window_label',
'height=345,width=550')">link_text</a>
This is utter nonsense, indeed.
But when the secondary window opens, the primary window reloads.
By chance: because the assignment to `location' comes first, it is
conceivable and reasonable that the second statement will not even
be executed.

But why, you are "reloading the primary window" yourself by assigning
a value to the `location' property. Stop that and use proper event
handlers, and nothing reloads.
I've seen earlier posts addressing this problem (or similar ones),
but I haven't been able to make any of the suggestions work. Any
guidance much appreciated.


....
<head>
...
<meta http-equiv="Content-Script-Type" content="text/javascript">
...
<script type="text/javascript">
function myOpen()
{
return! window.open(
'secondary_window.html',
'secondarywindowlabel',
'height=345,width=550'); // what about 640x480 or smaller?
}

// ...
</script>
...
</head>
<body>
...
<a href="primary_window.html" onclick="return myOpen();">link_text</a>
...
</body>
....

Still it remains unclear what you are trying to achieve _exactly_.
PointedEars
Dec 4 '05 #3
Since you ask what I'm trying to achieve, I'll risk boring you by
telling you, but first...

Your code worked!!! You're a genius, PointedEars! Thanks for the
helping hand.

Back to your question: I'm writing an html "book"--basically just a
long doc of scrollable text--on Bach. The text contains discussions of
many notated musical examples. I launch these examples in a smallish
secondary window. When I do this, I don't want the underlying "book"
text to reload--which would take the reader back to the beginning of
the text, rather than holding his reading-place in it. Hence the
importance for my purposes of kind of code you've kindly supplied.
Having given some context, maybe I'll push my luck with a follow-up
question. I'd like force the secondary window with the musical example
to stay visible ("on top"?), even if the reader returns focus to the
underlying text (which he may do to scroll around in the text while
continuing to look at the example to which it refers). I suspect
keeping a window visible in this way is more an HTML thing than an
javascript thing, but I thought maybe you'd know.... Thanks for any
help.

PS The notated musical examples are presented in a technology called
"Scorch" from a company called Sibelius. With this technology the
example can be played in audio, and as the music plays a kind of cursor
marches along with the notes: excellent aid for someone who can't read
music. (It also lets the listener slow the music down; again, useful
for the inexperienced listener who can follow events more easily if
they don't go by as quickly.) Scorch is enabled via a free plug-in
from Sibelius. If you're interested in things musical you might want
to check it out.

Dec 7 '05 #4
Thanks for the suggestions (and sorry for my ignorance; when I call
myself a newbie I'm understating the matter). I tried your solution,
and it helped (the primary window indeed did not reload), but somehow I
got TWO additional windows to pop up rather than just one (undoubtedly
because I messed up somehow). I played with ways of getting just one
additional window for a while without success, then tried the rather
different (I think) approach suggested by PointedEars in another
response to my post. That approach worked; got a single secondary
window to pop up without reloading the primary. Just wanted to thank
you for taking the time to respond. Another thing I'm a newbie at is
boards, and I'm very impressed with generosity and expertise to be
found on them.

Dec 7 '05 #5
skydanb wrote:
Since you ask what I'm trying to achieve, I'll risk boring you by
telling you, but first...
.... you wanted to quote the minimum of what you are replying to but
accidentally forgot it ;-)

Please take heed of <URL:http://jibbering.com/faq/faq_notes/pots1.html>.
Your code worked!!! You're a genius, PointedEars! Thanks for the
helping hand.
Thank you, too. And you're welcome.

Reviewing my code, the typo

return! window.open(...);

works because of the language grammar (see ECMAScript 3, 12.9 and 11.4.9),
however better code style is

return !window.open(...);

leaving whitespace between keyword and statement parameter, and placing the
operator `!' next to its operand.
Back to your question: I'm writing an html "book"--basically just a
long doc of scrollable text--on Bach.
Ahh, Bach :)
The text contains discussions of many notated musical examples. I launch
these examples in a smallish secondary window. When I do this, I don't
want the underlying "book" text to reload--which would take the reader
back to the beginning of the text, rather than holding his reading-place
in it. Hence the importance for my purposes of kind of code you've kindly
supplied.
Note that the approach I presented excludes users without client-side
scripting or popup blocker unless you include a viable alternative for
`primary_window.html'.

You may also want to consider using DHTML layers (layer, div and other
block elements that are displayed on demand and hidden when no longer
needed) as additional alternative to popup windows where the latter take
much more system resources (which are not always completely freed when
the window is closed, if it even opened [see: popup blocker]). In compliant
user agents, a show-on-hover feature even can be realized with CSS only.
Having given some context, maybe I'll push my luck with a follow-up
question. I'd like force the secondary window with the musical example
to stay visible ("on top"?), even if the reader returns focus to the
underlying text (which he may do to scroll around in the text while
continuing to look at the example to which it refers).
It is not possible to do that with client-side scripting alone. Attempts at
forcing the window to stay on top are futile and provably harmful if they
succeeed (think about other application windows).

<URL:http://developer.mozilla.org/en/docs/DOM:window.open>

Note that "dependent" windows are described to stay on top on Windows
platforms; this feature is not supported on MacOS X and dependent[=yes]
does not work here in Firefox/1.0.7 running with KDE 3.4 on GNU/Linux.

However, if you used DHTML layers, there would not be that problem.
(There would be another ;-))
I suspect keeping a window visible in this way is more an HTML thing than
an javascript thing,
No, HTML does not even "know" about windows. All that counts there
(and in CSS) is the client area, the viewport.
[Scorch] Scorch is enabled via a free plug-in from Sibelius. If
you're interested in things musical you might want to check it out.


Will do, thanks.
PointedEars
Dec 8 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Behzad | last post by:
Hi all I'am ASP programmer and I have built a site that users can upload and download files.All things store in a DB and everytime someone enters a page,the application requery the Db and shows...
4
by: D. Shane Fowlkes | last post by:
This may be a very simple question but I'm stumped none the less. I have a form where a user provides comments. There's a Grid below this form which displays all comments in the table so far. On...
5
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I force a reload from the server/prevent caching?...
1
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I force a reload from the server/prevent caching?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.