Click to See Complete Forum and Search --> : Visited Link
a.sh
February 15th, 2006, 11:19 AM
I have a link in Main Frame, and if people click on it and reload the same frame I need the link to show its been visited (ex: purple) and that works fine by default. However, after the user clicks on the link, if the user clicks on the Top frame to exit the program and come back to the page again, I need the link to not be visited, or purple anymore.
Is there anyway to code, if reload frame, link stay visited(purple) , else if exit frame and come back to frame, link not to be visited(blue).
Thanks.
This is my code for the link:
out.println("<TR><TD><A HREF=" + PdfFile + " TARGET='_blank' >" + linkname + "</A></TD></TR>");
PeejAvery
February 15th, 2006, 12:14 PM
Is there anyway to code, if reload frame, link stay visited(purple) , else if exit frame and come back to frame, link not to be visited(blue).
Either way the browser will consider it a visited link or a non-visited link. There is no true way to distinguish between the two options that you want.
a.sh
February 15th, 2006, 12:59 PM
Thanks for your reply.
Is there any way to say, if user clicks on a link(Exit) in top frame, change color or class of the link in lower frame in a different jsp file?
//This is my code for exit link in top frame. (title.jsp)
<a href="../TechPortal.jsp" onMouseOut="MM_swapImgRestore('t_Exit','t_Exit.gif');" onMouseOver="MM_swapImage('t_Exit','t_Exit_F2.gif');" onFocus="MM_swapImage('t_Exit','t_Exit_F2.gif')" onBlur="MM_swapImgRestore('t_Exit','t_Exit.gif');" target="MainFrame">
//This code is in frame1.jsp This is the link I need to be changed in lower frame when user clicks on Exit from title.jsp
out.println("<TR><TD><A HREF=" + PdfFile + " TARGET='_blank' + >" + linkname + "</A></TD></TR>");
PeejAvery
February 15th, 2006, 11:23 PM
Is there any way to say, if user clicks on a link(Exit) in top frame, change color or class of the link in lower frame in a different jsp file?
The only option that I can think of is to have it as a DIV and user innerHTML to re-write (from the upper window) the DIV content of the lower window.
a.sh
February 16th, 2006, 02:50 PM
I am trying to use window.parent.framename to access a link id and change the className but the code I wrote is not making any difference.
//x.jsp This is the link that I'm trying to access from y.jsp and change
out.println("<TR><TD><A HREF=" + PdfFile + " TARGET='_blank' + id='blue'>" + linkname + "</A></TD></TR>");
//y.jsp This is the code I wrote to change the className for the above link
window.parent.TaskPageFrame.blue.className = "blue";
Asok
February 16th, 2006, 02:55 PM
Questions:
1. Does it give an error of any kind, or does it just not change the class?
2. Do you own both .jsp files? (you're not crossing domains.)
3. Is the code you showed loading at the syncronously or async?
a.sh
February 16th, 2006, 03:21 PM
It doesn't give any errors, but it's not changing the class.
Yes, I have both the jsp files.
They are loading async.
The following code is in the title frame, when the user clicks on a button to exit the program I want it to change the class of the link in the lower frame so when the user initially loads the lower frame the link is blue.
//y.jsp This is the code I wrote to change the className
window.parent.TaskPageFrame.blue.className = "blue";
Thanks. Let me know if you have any other questions.
PeejAvery
February 16th, 2006, 03:46 PM
a.sh, this is still part of the original problem. Please do not post parts of an original problem into a new thread. Below is an example of what I was talking about.
frame.html
<html>
<frameset rows="50,*">
<frame src="top.html" name="topframe">
<frame src="bottom.html" name="bottomframe">
</frameset>
</html>
top.html
<html>
<body>
<a href="#"
onmouseover="javascript:parent.bottomframe.document.getElementById('divmain').innerHTML = '<a class=class1>Link style 1</a>'"
onmouseout="javascript:parent.bottomframe.document.getElementById('divmain').innerHTML = '<a class=class2>Link style 2</a>'"
>Over This...</a>
</body>
</html>
bottom.html
<html>
<body>
<style>
.class1{color:#000000;}
.class2{color:#0000ff;}
</style>
<div id="divmain"></div>
</body>
</html>
a.sh
February 16th, 2006, 05:16 PM
Thanks for the example.
I tried the following but the link still does not change color. I put the javascript: parent......code at the onClick event instead of onMouseOver, could that be a problem?
top.jsp
<html>
<body>
<a href="../TechPortal.jsp"
onClick="javascript: parent.TaskPageFrame.document.getElementById('divmain').innerHTML = '<a class=class1>Link style 1</a>'";
onMouseOut="MM_swapImgRestore('t_Exit','t_Exit.gif');"
onMouseOver="MM_swapImage('t_Exit','t_Exit_F2.gif');" onFocus="MM_swapImage('t_Exit','t_Exit_F2.gif')" onBlur="MM_swapImgRestore('t_Exit','t_Exit.gif');" target="MainFrame">
</body>
</html>
//bottom.jsp
<html>
<style>
.class1{color:#0000ff;}
</style>
<body>
out.println("<TR><TD><DIV id='divmain'><A HREF=" + PdfFile + " TARGET='_blank'>" + linkname + "</A></div></TD></TR>");
</body>
</html>
PeejAvery
February 16th, 2006, 05:22 PM
Where is the rest of the table? You have the TR and TD but not TABLE tags. Why are you using out.println?
The code that I gave you re-writes the innerHTML content of the DIV. The moment you click it, the DIV will be re-written with whatever you set the content to be.
a.sh
February 21st, 2006, 12:57 PM
Thanks. I was able to see the effect using the code you posted. However, using that method, the color changes once I click on the button, but when I exit the program and come back to load bottom.jsp the link color shows to be (visited)purple again.
Is there any way that every time the user clicks on the exit button in top.jsp, I can permanently change the link color in bottom.jsp from purple to blue?
PeejAvery
February 21st, 2006, 03:58 PM
Is there any way that every time the user clicks on the exit button in top.jsp, I can permanently change the link color in bottom.jsp from purple to blue?
If you want it permanent IN THIS MANNER, you will have to use cookies. I don't think that you want to go this deep.
You can just use the visited property but refreshing the window would have to occur.
Asok
February 22nd, 2006, 10:06 AM
Not necessarily. In the top.jsp, you could set a client-side variable stating what links were utilized in the lower frame. Then when the lower frame is returned to, do a check on the variable (boolean) and if it's true, set the classname to the blue style.
As long as the top.jsp file is never reloaded, this works fine.
Cookies would only be required if you want the knowledge of visitation to persist once the entire application is closed and re-opened.
PeejAvery
February 22nd, 2006, 12:46 PM
Cookies would only be required if you want the knowledge of visitation to persist once the entire application is closed and re-opened.
Which is what he/she wants.
That is why just plain client-side scripting will not solve this problem.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.