Forum Moderators: open
My main page (index.htm) has all of the navigation for the site.. pretty normal. Almost ALL of the links load external html files into a *dynamically* created layer (div) called "mainContent". I am also able to link to other files from within the 'mainContent" layer and they load into the same 'mainContent' layer within the index.htm file.
- I am NOT using an IFRAME anywhere (though I may have to to solve my problem)
This works perfectly, for the most part. Everything except a few pages that get loaded into new windows loads just fine into the 'mainContent' layer.
Here's the problem : The BACK button cannot be used with this method !
I need a way to make a 'back' button workable, even if its a back button that I create, long as it will take the user back in the history of external pages that have been loaded into the 'mainContent' layer.
It has been suggested to me that I could load the URL history into an array, and then access the 'history' in the array using a 'back' button. Well.. I've been slamming my head against that wall for 2-3 weeks and I just can't make it work :( My JS skills just aren't good enough to figure it out as soon as I need it.
Here is what was suggested:
var myHistory = []
function loadPage(url) {
myHistory.push(url)
myLoadPanel.load(url)
}
function back() {
myLoadPanel.load(myHistory.pop())
}
In this case, 'myLoadPanel' would be replaced with 'mainContent', the name of my main content layer.
I've tried and tried this, but I can't get it to work. Obviously I'm missing something/doing something wrong. Here is the script that is used for loading the external html files into the dynamic layer:
<a javascript:mainContent.setURL
'patient_check_in/sect_b_checking_in_patients.html'</a>
Questions:
1 - Is the definition attached here all that I need for the array to work ?
2 - Would I add the LoadPage function on the same line as the above link example ?
3- What scripting would I use for a 'back' button of my own making ???
I'm really, really stuck on this one, so if anyone can help me ASAP, I would greatly appreciate it. The site cannot go to QA for testing until this 'back button' problem is resolved.. and the site project is already 2 weeks behind (though not because of this) ! HELP!
If any more information is needed, I will gladly provide it either here or via email.. I'm getting to the point of desperation :(
Thanks in advance !
Besides, won't an invisible IFRAME with the same content as the layer just weigh down my pages ?? I don't need to make them slower, they need to be faster. I took this site from a 7-frame monster to NO frames. The Dynamic layers are VERY fast and I don't have to shift the content from an IFRAME to a div. The layers 'grow' lengthwise as needed and there are no hideous scrollbars like an IFRAME would need.
SE's ?? I'm not sure I know what you're referring to.. sorry. I have NO concern for any browser compatibility other than IE at this point either.
Thanks !
The reason you can't load the History list into an array is because you're not allowed to for security reasons; you could use it to spy on people's surfing habits and the information you could gather would be worth a small fortune to spammers.
There is only one way of doing it:
1. Find a company that issues certificates, such as VeriSign.
2. Pay that company a substantial fee and fill out a lot of personal details on a long form.
3. Wait until your details have all been checked out. You may get a visit from a company rep.
4. Write your script. It must include the line netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead")
5. Digitally sign all the scripts on the page. This involves creating a .jar file for each.
6. Upload. If you discover an error in your script, you will need to go through the signing process every time you make an edit.
7. Hope all your visitors are using Netscape browsers.
8. Hope all your visitors will grant UniversalBrowserRead privilege.
That's kind of a tall order just to avoid breaking the Back button...
First, this is an INTRANET_ONLY site, it will have NO exposure to search engines and the outside world.. their surfing habits to 'spy' on are of no consequence to me.... so, having said that..
why would I need to hope no one uses anything but Netscape ??? My target audience is IE only. I'm not using the Netscape Layer tag, I'm using DIV tags only.
As far as your 'one way' of doing it.. I beg to differ, as I've had input that says I CAN do it, and it does not entail a lot of complicated certificates, script-signing, or investigations.
Just for the edification of anyone who reads this, here is a bit of clarification on what I'm trying to do, and its NOT to circumvent browser security !:
"What you want to do... is something altogether different. You want to make your own little private history array, having nothing to do with the browser's history array. Yours only refers to URLs loaded into your own loadPanel. Those URLs are not recorded in the browsers history array."
loadPanel is an element of the DynAPI, a very slick API for DHTML, which is fairly advanced and can be found at SourceForge.net.
As if all these ads and other vehicles out there aren't tracking people's every move on the internet as it is, and they're NOT using signed scripts and certificates ! If I'm not mistaken, they're using sneaky little cookies.. which I personally keep a very tight lid on for my home pc.
Sorry that my dilemma is too radical a javascript/dhtml thing for this forum. Guess I won't get any help here !
<a javascript:mainContent.setURL
'patient_check_in/sect_b_checking_in_patients.html'</a>
Because that won't work at all. The event trigger needs to be set in the href attribute or the onclick attribute. But let's assume this is a typo.
1 - Is the definition attached here all that I need for the array to work ?
No, because your event trigger is wrong.
2 - Would I add the LoadPage function on the same line as the above link example?
<a href="javascript: loadPage('patient_check_in/sect_b_checking_in_patients.html');">This is a link</a> 3- What scripting would I use for a 'back' button of my own making?
<a href="javascript: back();">Back</a> and in the script element in the head:
function back() {
mainContent.load(myHistory[myHistory.length])
} But, again, not remembering much of DynAPI, I'm not sure if this is the proper syntax. Try asking the DynAPI mailing list (if there is one).
Sorry that my dilemma is too radical a javascript/dhtml thing for this forum. Guess I won't get any help here !
Sorry we're all too dumb to help you. Thanks for your support! ;)
At least you seem to know of the existence of the DynAPI, and you're right, DynAPI 2 has changed significantly since Dan Steinman came out with the original. I found the original a few years ago and was able to successfully use parts of it. Version 2 is different and more complex. I HAVE asked for help on the list and they apparently don't like my 'newbie' questions. I have gotten ONE response with some helpful information in it. My point is that we ALL have to start somewhere in learning and using JS, I admit that I got in over my head before I should have. But, I have, and now I need to learn more fast to fix it.
Now, the example that I posted DOES work, it IS attached to the HREF tag (sorry, just noticed the 'href=' is missing in what I included) and it works VERY well for loading my external pages into my dynamic layer. You're right.. it was a typo.. or at a least a bad copy/paste.
The corrected link tag with script reads as follows:
<a href="javascript:mainContent.setURL('ar_follow_up/section_a_guidelines_for_making_corrections.html')"><img src="wrapper_images/lftmenu_ar_01.gif" border="0" name="armenu_01"></a>
Everything about this works perfectly, EXCEPT for not having a functioning 'Back'-type button. That is what I need to resolve, and only that.
All in all, even though part of my post <a href> tag was missing, you have helped to answer at least part of my questions. Since I AM attaching to the 'href', does that change your answers to my 1st two questions ?
Thank you :)
<a href="#" onclick=javascript:history.back(-1)>BACK</a>
If it must be a button, then:
<form>
<input type=button value="BACK" onclick=javascript:history.back(-1)>
</form>
will give a standard OS button.
The problem with the 'normal' History object is that the URL's for the pages being loaded into my dynamic layer are NOT added to the browser's history. Essentially the URL of the page never changes, you basically start with 'index.htm' and stay there. All the other pages, except for a few loaded into new windows, get called as an external html file and are loaded into the dynamic layer (mainContent) that is embedded in the index.htm page.
I hope that makes sense :)
First.. I never said anyone here was too dumb to help.
Since I AM attaching to the 'href', does that change your answers to my 1st two questions
It depends. Again, I am operating a little in the dark here because I don't know how the DynAPI methods are constructed, but ... from what it looks like you have to be calling the loadPage function somewhere so that you can add the url to the myHistory array (I'm assuming here that that's what the push method does).
Looking at what you have posted here leads me to believe that you wouldn't be using the setURL method for these links like you are, but should instead be calling the loadPage function -- after all, what is the myLoadPanel.load(url) for? To me, it looks like the load method is what you use to load data into the div, so I would think you would have:
var myHistory = []
function loadPage(url) {
myHistory.push(url) // this should add the url to the myHistory array
mainContent.load(url) // this should change the url of the mainContent div
}
function back() {
mainContent.load(myHistory.pop()) // this should change the url of the mainContent div to the second-to-last url in the myHistory div
}
and you would call it like this:
<a href="loadPage('ar_follow_up/section_a_guidelines_for_making_corrections.html');"><img src="wrapper_images/lftmenu_ar_01.gif" border="0" name="armenu_01"></a>
Then you want the back button to look at the next-to-last url in the myHistory array (since the current page would be the last url). I guess that's what the pop method does. If so:
<a href="javascript: back();">Back</a>
should work.
I'd have to take a look at DynAPI to be sure though, and if you really are short of time you probably will want to harrass those unhelpful folks on the DynAPI mailing list... .
I wasn't trying to insult anyone.. guess I'm too far into freak-out mode to get this working.. LOL...sorry.
I know you probably don't have time to dive into the DynAPI, but does this help you understand what I'm doing with it so far ? :
<script language="Javascript" src="src/dynapi.js"></script>
<script language="Javascript">
DynAPI.setLibraryPath('src/lib/');
DynAPI.include('dynapi.api.*');
DynAPI.include('dynapi.event.*')
DynAPI.include('dynapi.gui.loadpanel.js');
</script>
<script language="Javascript">
<!--
DynAPI.onLoad=function() {
mainContent = new LoadPanel("psmain.html");
mainContent.setHTML();
mainContent.setSize(612,1200); // height will be overwritten by default
mainContent.moveTo(171,112);
mainContent.setBgColor('white');
counter = 0;
var el = new EventListener();
el.onload = function(e) {
//status = 'got load event '+ counter++;
}
mainContent.addEventListener(el);
DynAPI.document.addChild(mainContent);
}
The API really is very cool, but the documentation for the current version leaves something to be desired. I've had one guy from the list send me something I think I can use to fix this, just have to plug it in and try it. Along with what you've told me, I just MIGHT beat this thing into submission.
Thanks !
While it is possible to write a script to keep track of individual visitors' progress through your site, and while it is vaguely possible (using really really sneaky stuff) to find out what they do when they leave, it's not easy. JavaScript is "hobbled", and it is simply not possible to read properties of documents that originate from a different domain. You can access properties of documents from other servers at the same domain (e.g. orders.mydomain.com and sales.mydomain.com) but that's it.
It doesn't change the fact that access to the browser's History list is severely restricted. It is; and that's all there is to it. You may think it futile, but complaining to me about it isn't going to achieve anything.
I'm not complaining to you about anything ! You seem to miss my point.. my site is NOT on the internet, it is an INTRANET. It is NOT subject to any search engine, so I could care less about any SE 'compatibility'. I am NOT accessing ANYTHING outside of my own INTRANET server docs and I'm not tracking anything a user does except the pages loaded into my dynamic layer when they click links to files INSIDE my site. I don't care one little bit about 'tracking' anything else that's done or accessed in the browser, I don't care what they do when they leave the Intranet, and I'm not trying to be sneaky.
Perhaps my original request as to the 'browser's history' was inaccurate in relation to what I really need to do. You've read enough by now to know that I don't want to do anything with the actual BROWSER's history !