Link to home
Start Free TrialLog in
Avatar of dapperry
dapperry

asked on

Blow Away History Revisted?

In a previous question I asked whether you could blow away a  users history, or disable the back button.  The answer was 'No' and then we proceeded to come up with a long alternative of being able to process forms with history.replace()  Unfortunately the powers that be have decided that they now don't want forms submitted by url appendage (security stuff I guess).  Anyhow, the site I would be using this for would be a private one.  So I was wondering if you could use signed JS or use JS on https to get the proper permissions to do this from the user.  If this were possible I could get permission when a user first logs in to our site, and then after each new page is loaded, the history would be blown away.  This would be excellent becuase the user would then not be able to hit the 'Back' button and screw things up as they can now.  Let me know.

:) D Perry
Avatar of TTom
TTom

Don't know if this is what you are needing, but you can use a location.replace() method to ensure that subsequent pages do not appear in the browser history list.  This method is supported on Navigator 3.  Not sure about anything higher.  Using this method to load pages would ensure that users could not use the Back button to navigate through your site, but they could return from whence they came.

Will watch to see if this info is moving you in the right direction.

Tom (:-}
Avatar of dapperry

ASKER

No, my previous method of handling this matter was to use location.replace() (I inadverdently said history.replace())  This worked ok for links but was problematic for form submits.  The only way to do it this for forms was to build a large javascript function that evaluated all the form element names and values, and then created a url append string, and then did a location.replace(urlstring);  Unfortunately the powers that be do not want to use a url append string for security reasons.  We use Cold Fusion pages (.cfm) that is a combination of HTML and programming/querying.  Its a markup language, that does not use CGI scripts or programs.   So instead of loading .htm pages we load .cfm pages directly.  

So I want to actually delete a person's history, and not just load a new page without creating a history entry.  I was hoping by getting this type of permission once from the user through the use of signed javascript that I would be able to delete the person's history as each new page is loaded.  Please let me know if this is possible.

:) D Perry
Adjusted points to 200
Avatar of Michel Plungjan
I your previous discussion, did you come across expiring the page containing the form and POST the form?
Or even write the form with a cgi to begin with.
 That way a back would give you 'This page was a result of a post - to reload press the browsers. reload button...' Then the user would get 'Repost form data?'

Michel
To remove the history you should be able to do the following (in Netscape only):

<SCRIPT>
function removeHistory() {
   netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
   history = null;
   netscape.security.PrivilegeManager.disablePrivilege("UniversalBrowserWrite");
}
</SCRIPT>

If the user grants the access and does a remember this decision, he/she should not be bothered again
Some ideas, i missed the original question.

1. When you open a link in a new window, it starts a new history. You could make a "start" page in a window that stays open, and with every submit open a new window and close the old one.

2. Use a redirect after processing each form, when the user hits "back" he will be redirected forward again.

3. a script like this in each page:
<script>
if (document.location<>history(0)){history.go(0);}
</script>


Sybe: The content of the history object is not available in unsigned script so your 3rd suggestion would hit a security alert...
It would also just reload the page....

Also I believe it shold be
document.location != history[0].href

Michel


Michel

As your second remark, of course you are right...i am too much into VB right now :)

Your first remark makes me wonder. The thing is that the script does not ask for a value from the history array. I know the history array is secure, but not completely, because you can use "history.go(x)". Guess someone just has to test it. And then again, a secure script is no problem in this case.

Sybe
Actually you may only go(-1) , go(0) and go(+1) in IE(3?)...
Overall only history.length is readable.

Netscape 4+ allows more access without reading the url - you can actually go to a history entry containing a string : history.go('icrosof')
Using  netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
you may also do history.toString(), history.previous/next and current.

Reading up on this, there seems to be no href so the url would just be history[i]

Michel
I tried this bit of a script, but it did not work:

<SCRIPT>
   function removeHistory() {
      netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
      history = null;
      netscape.security.PrivilegeManager.disablePrivilege("UniversalBrowserWrite");

   }
</SCRIPT>
<BODY onLoad="removeHistory()">
This is the blowaway page
</BODY>

Can you tell me what I was doing wrong here?

:) D Perry
I am sorry. I assumed that since UniversalBrowserRead allows you read access, UniversalBrowserWrite would give you write access but alas, the history is a read/only object.
Even         for (i=0,n=history.length;i<n;i++) history[i] = null;
won't work...

You have tried or considered location.replace() and openeing in a new window each time?

I am out of ideas now...

Michel
Latest idea I'm considering is to open a new window at my login screen, which would have no buttons, location bar, menu, etc.  So therefore the user can not possibly hit 'Back' or 'Reload'  Two problems I've noticed with this methodology, so maybe someone could help on these and get the points for the question.  1) The user can still get a right mouse click menu to go back or reload the page, can we disable this? 2) I wanted to open a full screen window using the following code:

<SCRIPT LANGUAGE="JavaScript">
      function LoadNewWindow() {
            newwinfeatures="directories=no,menubar=no,toolbar=no,outerHeight="+screen.availHeight+",outerWidth="+screen.availWidth+",screenX=0,screenY=0";
            newwin=open("index2.html","newwin",newwinfeatures);
      }
</SCRIPT>
<HTML>
<BODY onLoad="LoadNewWindow()">
</BODY>
</HTML>

It seems however that MSIE 4 reads availHeight as 600 (on 800x600 screen) and does not compensate for windows taskbar.  Is there a workaround for this?

Answer these 2 ?s, and I think I'm good to go.

:) D Perry
Suggestion and a question:

Can you open your second window, close the first window, and set it up so that, when you are complete, you reopen another browser window with the tools, etc available.  You might have trouble with this using onunload, but you might be able to use a submit button or a close button with a function to do it.  If you really wanted to be funky about it, you might be able to capture the URL of the page that loaded the first page and send the user back to where they came from when they are done.

As far as the size, are you saying that, on an 800x600 window, the browser gets placed under (i.e., hidden by) the taskbar?  That's what happened on my machine when the taskbar was at the top and the y property was set to 0.  Setting it to 40 solved that one.  Unfortunately, when the taskbar was in other positions, the y property needed to be set to 0.  In any case, IE does not support outerWidth or innerWidth, so you still have a problem to contend with.

Good luck,

Tom (:-}
Here is one (only tested under Netscape - I cannot install IE for some reason...

<HTML>
<SCRIPT>
/* Cancel right mouse button
   (c) 1999 Michel Plungjan michel@irt.org */

NN = false;
IE = false;

if (document.layers) {
  NN = true
  window.captureEvents(Event.MOUSEDOWN);
}
if (document.all) IE = true;

if (NN || IE) window.onMouseDown=getMouse;

function getMouse(e) {
   if (NN) {
      if (e.which==3) return false;
      else {
         window.routeEvent(e);
         return true;
      }
   }
   if (IE) {
      if (window.event.button==2) {
         window.event.cancelBubble = true;
         return false;
      }
      return true;
   }
}
</SCRIPT>

</HTML>

Just looked it up (in HomeSite HTML reference) and NS is not supposed to support the screen property.  However, IE is supposed to allow for toolbars in its calculations.  Wonder if, for IE, you need to use ONLY availwidth and height and NOT specify the window position.

Tom
mplungian,
          Your script works fantastic on Netscape!  Unfortunately it doesn't work on IE 4. Our new required browser base is NS 4 or IE4.  Does IE 4 use Javascript 1.2?  Maybe it does use it, but only cruddily.  Let me know if you have any ideas for workarounds for IE.

ttom,
          Are you saying that I should not check availHeight and availWidth if its IE, but rather just screen.Height and screen.Width?  Under NS when I just set Height & Width of the new window the window got too big, but using outerHeight and outerWidth it made it the correct size.  Any suggestions here?  Is there like a maximize method, becuase thats essentially what I'm trying to do here.  Let me know.

:) D Perry
mplungian,
          Your script works fantastic on Netscape!  Unfortunately it doesn't work on IE 4. Our new required browser base is NS 4 or IE4.  Does IE 4 use Javascript 1.2?  Maybe it does use it, but only cruddily.  Let me know if you have any ideas for workarounds for IE.

ttom,
          Are you saying that I should not check availHeight and availWidth if its IE, but rather just screen.Height and screen.Width?  Under NS when I just set Height & Width of the new window the window got too big, but using outerHeight and outerWidth it made it the correct size.  Any suggestions here?  Is there like a maximize method, becuase thats essentially what I'm trying to do here.  Let me know.

:) D Perry
D:

This function pretty much does what you want in IE.  It's based on what you wrote earlier.  Don't know how it will work if taskbar is at the bottom, because then you want the window at the top.  Wierdly enough, if you just specify top=0, you get the new window loading up beneath the taskbar (at least I do.  But then, I get that kind of thing happening all the time on my machine.  Not sure if it's specific to my setup, or a general problem.).  OTOH, it could have to do with support for the 'top' and 'left' attributes, which is not guaranteed for IE.  I would like to think that specifying a window which uses all the available screen real estate would 'automatically' place it at 0,0, but my experience has not borne this out.  Play with this and see.  The thing to note about this is that the code is IE specific.  Height and width are the overall h and w and, avail h and w allow for taskbar.

I also looked at Michel's script for disabling the right mouse button, and was not able to come up with anything that could be changed to make it work.

Sorry!

<SCRIPT LANGUAGE="JavaScript">
function LoadNewWindow() {
newwinfeatures="directories=no,menubar=no,toolbar=no,width="+screen.availwidth+",height="+screen.availheight+",left="+(screen.width-screen.availwidth)+",top="+(screen.height-screen.availheight);
newwin=open("test2.html","newwin",newwinfeatures);
}
</SCRIPT>

Tom (:-}
I am sorry the script does not work in IE

The syntax is supposedly correct and IE 'aught' to be able to do it with my code and IE always does what one expects so it must be something I am missing in the script (yeah right!) - seriously though... I will try to find an IE to test it on since I wrote the script from documentation only (but did test it in NS)

Michel
It did take some hunting - it seems IE does not conform to it's own documentation - NEWS AT 11

Here is one - I am afraid the alert is VERY necessary - nothing but an alert is allowed



       <HTML>
       <SCRIPT>
       /* Cancel right mouse button
          (c) 1999 Michel Plungjan michel@irt.org */

       NN = false;
       IE = false;

       if (document.layers) {
         NN = true
         window.captureEvents(Event.MOUSEDOWN);
       }

       if (document.all) IE = true;
       if (NN || IE) window.onmousedown=getMouse;

       function getMouse(e) {
          if (IE) {
             if (window.event.button==2) {
                alert('Right mousebutton disabled');
                window.event.cancelBubble = true;
                return false;
             }
             return true;
          }
          else if (NN) {
             if (e.which==3) return false;
             else {
                window.routeEvent(e);
                return true;
             }
          }
       }
       </SCRIPT>
<script language=vbscript>
sub document_onmousedown
   getMouse()
end sub
</script>
</HTML>

Michel
Still doesn't seem to work on IE.  Still get menu, and alert never comes up.  Maybe its a typo or something, so I won't reject answer right away.

:) D Perry
Well it worked in IE4.01sp1 under NT4 so I am afraid you better reject the answer - Sorry

Michel
Please review the way I have the code laid out.  First I have an index.html -

<SCRIPT LANGUAGE="JavaScript">
      function LoadNewWindow() {
            newwinfeatures="directories=no,menubar=no,toolbar=no,outerHeight="+screen.availHeight+",outerWidth="+screen.availWidth+",screenX=0,screenY=0";
            newwin=open("index2.html","newwin",newwinfeatures);
      }
</SCRIPT>
<HTML>
<BODY onLoad="LoadNewWindow()">
</BODY>
</HTML>

Then I have an index2.html -

      <SCRIPT>
          /* Cancel right mouse button
             (c) 1999 Michel Plungjan michel@irt.org */

          NN = false;
          IE = false;

          if (document.layers) {
            NN = true
            window.captureEvents(Event.MOUSEDOWN);
          }

          if (document.all) IE = true;
          if (NN || IE) window.onmousedown=getMouse;

          function getMouse(e) {
             if (IE) {
                if (window.event.button==2) {
                   alert('Right mousebutton disabled');
                   window.event.cancelBubble = true;
                   return false;
                }
                return true;
             }
             else if (NN) {
                if (e.which==3) return false;
                else {
                   window.routeEvent(e);
                   return true;
                }
             }
          }
          </SCRIPT>
   <script language=vbscript>
   sub document_onmousedown
      getMouse()
   end sub
   </script>
<HTML>
<HEAD>
<TITLE>RapidTRACK</TITLE>

      <FRAMESET ROWS="30, *" FRAMESPACING=0 FRAMEBORDER=0 BORDER=0>
      <FRAME NAME="header" SRC="/scripts/RTAdminLive/logohead.cfm" SCROLLING="NO" MARGINHEIGHT=0 MARGINWIDTH=0 NORESIZE FRAMEBORDER="NO" FRAMESPACING=0>
      <FRAME NAME="body" SRC="/scripts/RTAdminLive/login.cfm" MARGINHEIGHT=10 MARGINWIDTH=10 NORESIZE FRAMEBORDER="NO" FRAMESPACING=0>
      </FRAMESET>

</HEAD>

<BODY BGCOLOR="#FFFFFF">
</BODY>
</HTML>

You can also test this by going to www.rapidtrack.com/rtadmin/
You should then get a new window without buttons or menus, and with NS you won't get a right click menu.  I've also installed and tried IE 4.01 sp1, and it still doesn't work.  Maybe I've just set up the code in my pages wrong.  Let me know.

:) David
daperry:

I may have found it!!! (Actually, not me, but someone on one of the MS newsgroups.)

Try inserting the following code into Michel's/your solution:

       function getMouse(e) {
          if (IE) {
             if (window.event.button==2) {
                alert('Right mousebutton disabled');
                self.event.cancelBubble = true;
***             window.event.returnValue = false;

*** is the key line.  I think this will make the code work for IE.

Tom (:-}

In my IE4 - it does it's thing with or without the returnValue...

IE 4.01sp1a
4.72.3110.8

under NT4sp3 on a p233 64MB

Michel

Michel:

Interesting.  Same build, same SP, under W95, p90, 80mb.

When I put the extra line in, I got the alert, but no 'right click menu'.  Actually seems to work with your original code now.  Go figure!   I thought David was having problems getting it to work?  Seems window.event.returnValue = false is the same as return false;

I don't know.

Tom (:-}


Tried Ttom's revision, but it makes no difference. The event never fires.  Does it have anything to do with the fact that index2.html opens a frameset in the new window?  Let me know - I can smell that we're close here, so I want to bring it all in.

:) D Perry
If you are trying to disable the right mouse button in the NEW window (or the frames in that window), the code will have to be inserted in that window (or those frames).  If the new window has pages over which you have no control, you are going to be in trouble.  You might(?) be able to do this with the function in the frameset page, but I am a bit skeptical about that.  The function will need to be in the page where you want it to take effect (perhaps as an included file to save copying).

Note that the only way for it to function in IE is with the alert.

HTH,

Tom (:-}
Yes I'm trying to stop the menu totally, including in the new frames.  I mean there is only 1 main frame.  The other 2 are merely for a logo, and for navigation buttons.  I would prefer  not to include the code in every new page, but if thats what your telling me I need to do than that isn't a problem.  The alert isn't too problematic either.  I can just have an alert that says 'Right mouse menu disabled.' and that shouldn't be too awkward.

:) D Perry
I think that's the way you're going to have to take it.  I would investigate using includes or references, e.g.

<script scr="rtmenu.js"></script> to minimize typing and centralize control.

Tom (:-}
Let me know if you find that it works - then perhaps I can resubmit as an answer?

Michel
Mplungian,
       Yeah - that works.  Submit an answer and the points are yours.

TTom,
       I'll submit another question just for you - although I would like some clarification on how to get the maximized window to open for NS 4 and IE 4.
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
w=800;
h=600;
if (window.screen) {
   w = screen.availWidth;
   h = screen.availHeight;
}
WinHandle = window.open('file.html','newwin','width='+w+',height='+h+',top=0,left=0,screenX=0,screenY=0');

Michel

Dave:

I think we've dealt with the maximized window thing before (other questions).  What Michel puts forth works (I'm pretty sure) for IE.  I have had problems with the (position and visibility of the) taskbar on my machine, so I am not really happy with this construction.  Some more research on the NS site seems to indicate that NS might also support this construction, but I don't know for sure.

BTW, I have just found a reference to the possibility of opening a "fullscreen" window (i.e., kiosk mode) in IE.  Don't know how well supported it is, or if it's what you are looking for, but apparently it exists (window.open ('','','fullscreen=yes,...')).

HTH,

Tom (:-}
TTom: I am NS first and IE second. Until recently I could not test my utterances in IE4, but the code should work in both with normal placement of taskbars - no 'might' about it ;-)

I did not suggest fullscreen since it is IE only and it will stop you from adding any properties such as status...

Michel
Michel:

I tested the code in both and it worked.

My problems are two.

The documentation I was working with (primarily HomeSite) indicates that 'screen' is supported only by IE.  That is apparently not true.  Since availWidth and availHeight are 'screen' attributes, I could not say unequivocably that they would be successful in NS.

I have played with this code a number of times.  In every case, ON MY MACHINE, I have had difficulties with window placement.  These difficulties always relate to the position and properties of the taskbar.  If I place the window at 0,0 and my taskbar is visible at the top of the screen, either the window is placed over the taskbar or under it.  Ergo, I am hard pressed to say that this is an 'error-free' solution.  I have pointed this out in more than one case where people have been looking for a 'maximized window' solution, and I have always indicated that this could be a problem with my particular configuration.  That having been said, it still indicates to me a potential problem (maybe I need to upgrade my machine <G>).

You are absolutely right about the 'fullscreen' option, and I only pointed it out because I had never run into it before.  I thought it deserved a mention.

I have figured out that you are an NS person, and it's good to know, since I think you are a tremendous resource (even on the IE side).  You are what the EE should be all about, and you've earned every point you have.  Your answers are thorough and precise.  I learn from them all.

(I have to remember to keep from trying to be 'competitive'.)

Kind regards,

Tom (:-}
Here's a script from http://www.dynamicdrive.com.  It's much more efficient and works for NN6 as well.  It also doesn't produce a pop up message.

hth

jessey


--------------

<script language=JavaScript>
<!--

//Disable right click script III- By Renigade (renigade@mediaone.net)
//For full source code, visit http://www.dynamicdrive.com

var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")
// -->
</script>
jessey,
Thanks for sharing the script. It is a little bit nicer in that it doesn't require the alert.

:) David