• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 996
  • Last Modified:

JavaScript: How do you create a back link to a specific page?

Good day;

I have been using the following JavaScript in my web page, which works rather well:

<a href="javascript:history.back(1)">

Basically, I use the history tag in the above script which takes me to the previous page and it closes the active window.  This is very handy if your active window consists of Frames.
However; I need a link on my web page that closes the active windows (Frames or no frames) and takes you back to a specific page.  How can I do that?  I need no buttons or anything just a typical link.  
Currently, all I have been able to do is go back to the previous page.  Would someone help me with this?

Thanks
0
abastanpour
Asked:
abastanpour
  • 5
  • 3
1 Solution
 
LawrenceAlanCommented:
<a href="javascript:document.href='url';">text</a>

ie: <a href="javascript:document.href='http://google.com/';">Google</a>
0
 
LawrenceAlanCommented:
sorry maybe you should use document.location instead,

<a href="javascript:document.location='url';">text</a>

ie: <a href="javascript:document.location='http://google.com/';">Google</a>
0
 
abastanpourAuthor Commented:
Good day;

Well the document.location works, however it does not close the active window.  I have a page consists of frames and I need it to goto another document.location and close the active window.
Right now when I use the document.location it opens the http://google.com in the middle frame.

We are getting close.. any ideas?
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.

 
LawrenceAlanCommented:
By clear the active window do you mean clear all the frames?

try this:

<a href="javascript:window.location='http://google.com';">Google</a>
0
 
abastanpourAuthor Commented:
I mean to close the active web page being displayed in IE, then open a new IE windows to Google or any other page.
Now, keep in mind that my page is made of three frames.  The code above displays Google in the middle page.  
I need it to clear/close all frames and take me Google or another page.  
Take a look at the web site I am working on: http://www.bradshawestates.com
Navigate to gallery link then hit the previous page link.  You see it closes the gallery page which is a frame.
Now on the gallery page, if you choose to see several pictures and then use the previous windows link, it will take you back to previously looked at picture.  I need it to take me back to the home page.
All the codes that I have seen displays the home page or in your case Google.com in the center frame.
I hope this helps.. Sorry, I don't explain well..  Hope you can help.. :)
0
 
LawrenceAlanCommented:
Ok this helps, honestly, my suggestion to you is to learn how to use DIVs :) Frames are not well looked upon.

Here's a workaround; Add the script below, and change your link to javascript:goBack();

In "includetopframGall.htm":
<html><head>
<!-- Start new code -->
<script>

function goBack() {
var currentURL = new String;
currentURL = parent.window.location + '';
if (currentURL.indexOf('galleryFrame.htm') > -1) {
      parent.window.location = 'http://www.bradshawestates.com/';
} else {
      document.history.back(1);
}

}
</script>
<!-- End new code -->


0
 
LawrenceAlanCommented:
That script is if you used the same html in the top frame for every page on your site, you could just use:

<a href="javascript:parent.window.location='http://www.bradshawestates.com/';">Previous Page</a>

All depends on how your site is going to work.
0
 
abastanpourAuthor Commented:
Thank you :)
This works very well:  <a href="javascript:parent.window.location='http://www.bradshawestates.com/';">

I do need to understand and learn DIVs:  Not sure where I can start learning about it.  Perhaps an easy editor/software that would walk me through.  If you know one.. Please let me know, and you have any suggestions for our community web site please let me know..

Thank you :)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now