I'm using this code to show and hide a div. -
function showDiv(){
-
document.getElementById("test").style.visibility="visible"
-
}
-
-
function hideDiv(){
-
document.getElementById("test").style.visibility="hidden"
-
}
-
The link to hide the div is in another frame and it works fine.
When it is hidden a background image is visible and I've made it clickable with this: -
#box-link {
-
position: absolute;
-
top: 21px;
-
left: 21px;
-
width: 267px;
-
height: 180px;
-
background-color: transparent;
-
border: 1px solid yellow; }
-
-
and this: -
<div class="box-link" id=test2><a id="box-link" href="" onClick="javascript:showDiv()"></a></div>
-
It works fine if I create a link in the other frame but it will not work in IE from the transparent box link div. Instead of making the div visible again, it goes to the directory page showing a list of files. It works perfectly in Firefox. But this is for an offline app in an app specific browser based on IE. So I don't care if it works in other browsers. Just IE.
Thanks in advance for any suggestions.
Okay... And your div would still appear and disappear, but every time that it did, the user would jump to the top of the page.
I'm still not sure what's so hard about adding the line "return false;" to the end of your functions, though...
10 2240
Well after spending a ridiculous amount of time trying to figure out the problem, I figured it out. All I had to do was add an # to the href=
You need for your event handler functions to return false.
That cancels the default action of the click, which is to navigate to the page in the href attribute. Setting the value to be "#" will only force the page to jump to the top.
Thanks for the reply. If what you mean by "jump to the top" is making the div visible, that is what I wanted. Regardless, it works now and all I did was add the #.
thanks
No, what I mean is that you are sending your users to the empty anchor (as opposed to an anchor like "#content" or "#nav"), which sends them to the top of the page. Once you have a page that is large enough to scroll, you'll see it.
The page is of a set size in an iframe. So that won't be an issue but for the sake of learning something, I changed it to #nav. The action is taking place in an iframe. There are two divs. One is a page and the other is a transparent image so that you can see a background image that is clickable. So the only page is the hidden div. But if everything was taking place on my main page and there was no iframe, in that case, without adding content or nav, my div would not reappear, but instead the main page would jump to the top?
Thanks again
Okay... And your div would still appear and disappear, but every time that it did, the user would jump to the top of the page.
I'm still not sure what's so hard about adding the line "return false;" to the end of your functions, though...
I'm only just learning. I didn't understand what you meant by return false before. I added it to the end of my functions. And now I know the proper way to do it.
Thank you.
Oh, okay. I didn't realize that was the issue. Good to see that we're on the same page, now. :)
Also, there's a difference between "visibility:hidden" and "display:none". The former makes the object invisible, but keeps it's position in the document so that no other elements are moved. The latter removes the element from the document (it can be restored by giving the display style a different value, such as "block").
In this case my hidden div has windows media player controls in it and it continues to play even when hidden. with display:none, would it close and stop playing?
thanks
No, it wouldn't. Though, you can probably force it to stop via JavaScript. How, I'm not sure. Sorry.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: oLE |
last post by:
I would like to add some javascript to show/hide a certain row of a
table. The first row of the table contain the hyperlink that calls the
javascript the second row is the one i want to show/hide...
|
by: alex |
last post by:
I'd like to have a show/hide widget on my web site, kind of like "show
details" / "hide details" in Google Groups. Is there a tutorial
explaining how to make them? Google's is a bit complex and...
|
by: Mateo |
last post by:
Hi!
I have a litle JS problem.... I'm trying to make show/hide table JS
function, but my show/hide table
function works only on IE.... It works in mozilla partially. Actually,every
time when I...
|
by: dje |
last post by:
In the OnClick event on a radioButtonList, I run a javascript to
show/hide the appropriate div along with a submit button, which
displays as expected. The problem is the submit no longer works on...
|
by: bridgemanusa |
last post by:
Hi All:
I have a very long page of html that I want to take portions and hide
them in divs, then show when a link is clicked. I have the hide show
part working when the link is clicked, however...
|
by: FP |
last post by:
I'm new to Java Script.
I'm displaying comments people have made. Below each persons' comment
I want to add 2 buttons "Reply" and "Amend". Clicking "Reply" would
display an empty text field...
|
by: therealvibe |
last post by:
I have made a simple page with show hide layers with javascript and
css.
http://www.icatt.nl/special/test/salarisstrook_algemeen.html
The idea is that the blue help text rechtangle will have...
|
by: pamate |
last post by:
hi,
I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers.
...
|
by: ryrocks |
last post by:
Hi,
Im making a 'contact us' page. The user click on the div, this then reveals another larger div displaying more information giving the effect of the box expanding or dropping down.
I have 3...
|
by: may bailey |
last post by:
Hi all,
I have been trying to use a show / hide script on my web site but when
I click on the "hide" button there occurs an error with explorer 7.
The web site starts to go down =) and there...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |