 |
 |
Javascript help!
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Status:
Offline
|
|
Ok, I'm not that good with javascript, but here's what I want to do:
On one page I have a list of links that open up a pop-up page when you click them. They dynamically create the content depending on what link you clicked. The problem is that when you click multiple links, the pop-up doesn't refresh, but adds the additional content. How do I clear this popup, so that I can have only one thing going on inside it when someone clicks multiple links?
Another problem I have is that because I use an iFrame on one of my pages, the page fails to update sometimes when I update the iFrame'd page. I'd like to insert a javascript so that whenever the page loads once, it will reload again (but only once!). I have a problem because I've gotten it to reload, but it reloads indefinitely.
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Status:
Offline
|
|
ok i've figured out the refresh part, now i just need help with that new page thing.
|
|
|
| |
|
|
|
 |
|
 |
|
Registered User
Join Date: Jul 2003
Location: San Jose
Status:
Offline
|
|
try this...
[php]
<html>
<head>
<script language="JavaScript">
<!--
function newWin(url, name)
{
window.open(url, name)
}
// -->
</script>
</head> ...
[/php]
and then your links...
[php]
<a href="javascript:newWin('page1.html','main')">link 1</a> <br>
<a href="javascript:newWin('page2.html','main')">link 2</a>
[/php]
make sure that the name of the popup window is always the same, in this case 'main'. that way the browser will know to always put the content in the same window.
is this kind of what you were looking for? if not, post up what you have so far so we can see what you're trying to do.
note: there should be no spaces in 'javascript' in your link.
(Last edited by mzllr; Oct 5, 2003 at 03:57 PM.
)
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Status:
Offline
|
|
Thanks mike, but my problem is a bit differnt, perhaps I didn't explain well enough.
I have just that what you showed me, but the page it opens is created by the javascript, and is not an html page that I have lying around somewhere. I need to be able to "refresh" the contents each time another link is pressed, because other wise document.write's just pile on.
to see what I mean go here and click several links without closing the window.
|
|
|
| |
|
|
|
 |
|
 |
|
Registered User
Join Date: Jul 2003
Location: San Jose
Status:
Offline
|
|
ahhh, sorry, i get what you're trying to do now...
this might work...
[php]
<script type="text/javascript">
<!--
function play(file, thename) {
var song_window = open("", "song_window", "resizable=no, toolbar=no, location=no,
directories=no, status=no, menubar=no, height=125, width=300");
song_window.focus();
song_window.document.close();
[/php]
adding "song_window.document.close();" should clear the content.
(Last edited by mzllr; Oct 5, 2003 at 05:02 PM.
)
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Status:
Offline
|
|
YES! YES!! THIS WORKS!! Thank you!
You have no idea how both painful and humbling this is. I didn't know that would work, I thought that would close the window. You might find this funny (this is what I was working on):
[php]
<script type="text/javascript">
<!--
opened = 0;
-->
</script>
<script type="text/javascript">
<!--
function play(file, thename) {
song_window = open("", "song_window","resizable=no,toolbar=no,location=no ,directories=no,status=no,menubar=no,height=125,wi dth=300");
song_window.focus();
if (!opened) {
song_window.document.write("<html><head><link href=\"main.css\" rel=\"stylesheet\" media=\"screen\"></head><body><center><h1>" + thename + "</h1>");
song_window.document.write("<embed height=\"16\" kioskmode=\"true\" name=\"file\" type=\"audio/mpeg\" width=\"270\" autostart=\"true\" src=\"" + file + "\" autoplay=\"true\" controller=\"true\">");
song_window.document.write("<p><a style=\"font-size: 10px\" href=\"javascript :window.close()\">Close</a><span style=\"font-size: 11px; font-family: Arial\"><br>Copyright © 2003 Kinostudios.com</span></p></center></body></html>");
opened=1;
}
}
-->
</script>
<script type="text/javascript">
<!--
function rld() {
if (opened==1) {
song_window.close();
opened=0;
}
}
-->
</script>[/php]
 I got it to work with Mozilla, but Safari is stupid and would simply load then close the page (when it's supposed to close, then reload the page).
The links would have "javascript :rld();play(asdfdaf)"
|
|
|
| |
|
|
|
 |
|
 |
|
Registered User
Join Date: Jul 2003
Location: San Jose
Status:
Offline
|
|
Originally posted by itistoday:
YES! YES!! THIS WORKS!! Thank you!
You have no idea how both painful and humbling this is. I didn't know that would work, I thought that would close the window.
no problem, glad it worked out.
about a year ago, i had a similar setup so that i could put mp3's on my idisk and then listen to them from work through a browser. after hours of going through the javascript manual, i finally got the page to clear (so i definitely know how frustrating it is)...
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|