?
Solved

BACK / FORWARD BUTTONS IN POPUP WINDOW

Posted on 2003-03-10
10
Medium Priority
?
230 Views
Last Modified: 2008-02-01
Hi experts,

I have 2 asp-pages that I need help with:

www.deutschschule.net/test/main.asp

Please visit this page and follow the simple instructions. It is my first trial of a pop up window. The following problems I couldn't solve yet:

How can I disable the BACK / FORWARD buttons when necessary?

I tried:

if (history.previous) {document.frm.cmdPrevious.disabled=true;

   and

if (history.previous) {document.frm.cmdPrevious.enabled=false;

Where do I put the code?

I put this code after the "window.focus();" command and I tried to put it into the body-tag's onLoad / onFocus events, with no results.

Please help. This is important for me. Thank you in advance

BL
0
Comment
Question by:beni_luedi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 5

Expert Comment

by:JimV_ATL
ID: 8108357
Check out this very well written previous answer:

http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20121885.html
0
 
LVL 10

Accepted Solution

by:
kollegov earned 500 total points
ID: 8108369
From onLoad event call function to enable disable buttons

<html>
<script>

function adjust() {
alert(history.next==null)
  document.frm.fwd.disabled =  (history.next==null)
  document.frm.back.disabled = (history.previous==null)
}

</script>
</html>

<body onLoad="adjust()">

<form name="frm">
  <input type="button" name="fwd" onClick="history.forward(); return false;" value="FWD">
  <input type="button" name="back" onClick="history.back(); return false;" value="BACK">
</form>

</body>
0
 
LVL 10

Expert Comment

by:kollegov
ID: 8108383
Oooopsss alert remained from tests  :))
You of course do not need it :))
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:beni_luedi
ID: 8108665
hi kollegov,

I changed it according to your suggestions, but when I open the popup window for the first time, both buttons are enabled, but they shouldn't. After the second and third loading of the page both buttons are still enabled.

I tried it on my PWS, and I uploaded it too, but right now I get the error message: "The document contains no data." when I try my online version. Perhaps you can try it, and it will work. If I made a mistake, please tell me.

0
 
LVL 10

Expert Comment

by:kollegov
ID: 8108999
Oooopssss IE do not support next and previous in history object ! ( my mistake )
All what it have is

back ()     -  Loads a URL from the History list.
forward() -  Loads the next URL in the History list.
go(n)        -  Loads a URL from the History list.
length       -  Retrieves the number of objects in a collection

And that's all it have :(  next and previous is NN only... Damn...

So all what you can do for MIE is to implement history manually (programmaticaly)
But this have advantage as it do not erase untill you close main window :)

In your main window you can add

<script language="JavaScript" type="text/javascript">
var hist  = new Array();
var pos = 0;

function PopUp() {
  var url =' keke.html?YourValue='+document.frm.txt.value
  hist[pos] = url;
  pos++;
  hist.length=pos;
  window.open(url,
     'PopUp', 'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1, width=625,height=300,top=30,left='+(screen.width - 665));
}
</script>

-------------------
Then your popup
<html>
<script>

function adjust() {
              document.frm.back.disabled =  (opener.pos<=0)
              document.frm.fwd.disabled = (opener.pos>=opener.hist.length-1)
}

function goHist(n) {
  opener.pos+=n;
  if(opener.pos<0) opener.pos=0;
  if(opener.pos>=opener.hist.length) opener.pos=opener.hist.length-1;
  self.location.replace(opener.hist[opener.pos])
}

</script>


<body onLoad="adjust()">

<form name="frm">
     <input type="button" name="fwd" onClick="goHist(1); return false;" value="FWD">
     <input type="button" name="back" onClick="goHist(-1); return false;" value="BACK">
</form>

</body>
</html>
0
 

Author Comment

by:beni_luedi
ID: 8109723
I give up. I spoiled one full day on this. Now I am tired. I thourght it is quite easy, but it isn't. I can't make it work. I am talking about your first version. I doesn't work on NN neighter.

And your second version seems to be too complicated to work through it. It is anyway only a small effect.

But you get the points anyway.

Thanks ...

BL
0
 

Expert Comment

by:Ichitaka
ID: 8110029
In javascript the "=" is used to assign a value, and te "==" to compare.
In your popup.asp write:

if (history.length==1) ...

instead of

if (history.length=1) ...

and something goes better. :-)
0
 
LVL 19

Expert Comment

by:webwoman
ID: 8112153
A popup window doesn't have a history -- history is specific to the window, not the browser. You haven't been anywhere, you haven't gone anywhere, you don't have any history for that window.
0
 

Author Comment

by:beni_luedi
ID: 8115839
I do have history. My Back / Forward command button, that I put on the page, work perfectly. I just can't disable them when necessary. For example when I call the window for the first time both buttons should be disabled. Just the same way like the once in the toolbar above. But anyway. Let's forget it. Thanks for all the answers.

BL
0
 
LVL 10

Expert Comment

by:kollegov
ID: 8116630
If you check this 2 files as is then it works :)

----------------------  main.html ---------------
<html>

<script language="JavaScript" type="text/javascript">
var hist  = new Array();
var pos = 0;

function PopUp() {
  var url =' pop.html?YourValue='+document.frm.txt.value
  hist[pos] = url;
  pos++;
  hist.length=pos;
  window.open(url,
     'PopUp', 'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1, width=625,height=300,top=30,left='+(screen.width - 665));
}
</script>

<body>

<form method="POST" name="frm">
        <p>PLEASE INSERT A VALUE AND PRESS THE BUTTON:<br><br>
                <input type="text" name="txt" size="20">&nbsp;
                <input type="button" value="PopUp" name="cmdPopUp"
                OnClick="PopUp(); return false;"><br><br>
                THIS IS A POP UP TEST PAGE !!!<br>
                PLEASE ENABLE POP UP'S FOR: www.deutschschule.net
        </p>
</form>
</body>
</html>
-------------------------------- pop.html ----------------------------
<html>
<script>

function adjust() {
              document.frm.back.disabled =  (opener.pos<=0)
              document.frm.fwd.disabled = (opener.pos>=opener.hist.length-1)
}

function goHist(n) {
  opener.pos+=n;
  if(opener.pos<0) opener.pos=0;
  if(opener.pos>=opener.hist.length) opener.pos=opener.hist.length-1;
  self.location.replace(opener.hist[opener.pos])
}

</script>


<body onLoad="adjust()">

<form name="frm">
     <input type="button" name="fwd" onClick="goHist(1); return false;" value="FWD">
     <input type="button" name="back" onClick="goHist(-1); return false;" value="BACK">
</form>

</body>


0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question