Hey there guys
I am having a little trouble with InnerHTML as i can't seem to figure out how to set the style of my div tag.....
What im trying to do is that when i rollover pic1 it changes that pic and displays:block and visiblity:visib le....and also changes pic2..
When the webpage is loaded it displays:none and visivlity:hidde n also
Heres my code: -
<html>
-
<head>
-
<script type="text/javascript">
-
function start(){
-
document.getElementById('pic1').src="icons/on1.jpg";
-
document.getElementById('aa').innerHTML = "<div style=visibility:visible; display:block;>";
-
document.getElementById("bb").innerHTML = "<div style=visibility:hidden; display:none;>";
-
document.getElementById("pic2").src="icons/off2.jpg";
-
}
-
-
function one1(){
-
document.getElementById('pic1').src="icons/on1.jpg";
-
document.getElementById('aa').innerHTML = "<div style=visibility:visible; display:block;>";
-
document.getElementById("bb").innerHTML = "<div style=visibility:hidden; display:none;>";
-
document.getElementById("pic2").src="icons/off2.jpg";
-
}
-
function two2(){
-
document.getElementById('pic1').src="icons/off1.jpg";
-
document.getElementById('aa').innerHTML = "<div style=visibility:hidden; display:none;>";
-
document.getElementById("bb").innerHTML = "<div style=visibility:visible; display:block;>";
-
document.getElementById("pic2").src="icons/on2.jpg";
-
}
-
</script>
-
<style type="text/css">
-
#aa { visibility:hidden; display:none;}
-
#bb { visibility:hidden; display:none;}
-
</style>
-
</head>
-
<body onLoad="start()";>
-
-
-
<div id="aa">
-
bla bla bla bla bla bla
-
</div>
-
<div id="bb">
-
da da da da da da da da da da da
-
</div>
-
-
-
<img id="pic1" src="icons/off1.jpg" width="50" height="50" onMouseOver="one1()"/><br />
-
<img id="pic2" src="icons/off2.jpg" width="50" height="50" onMouseOver="two2()"/><br />
-
</body>
-
</html>
-
Please help !!!!! i just need to find out how to change the style to invisibility:vi sible and display:block through the innerHTML!!!!
Thanks a million!!
Ricky
8 10112 Delerna 1,134
Recognized Expert Top Contributor
Hey there guys
I am having a little trouble with InnerHTML as i can't seem to figure out how to set the style of my div tag.....
What im trying to do is that when i rollover pic1 it changes that pic and displays:block and visiblity:visib le....and also changes pic2..
When the webpage is loaded it displays:none and visivlity:hidde n also
Heres my code: -
<html>
-
<head>
-
<script type="text/javascript">
-
function start(){
-
document.getElementById('pic1').src="icons/on1.jpg";
-
document.getElementById('aa').innerHTML = "<div style=visibility:visible; display:block;>";
-
document.getElementById("bb").innerHTML = "<div style=visibility:hidden; display:none;>";
-
document.getElementById("pic2").src="icons/off2.jpg";
-
}
-
-
function one1(){
-
document.getElementById('pic1').src="icons/on1.jpg";
-
document.getElementById('aa').innerHTML = "<div style=visibility:visible; display:block;>";
-
document.getElementById("bb").innerHTML = "<div style=visibility:hidden; display:none;>";
-
document.getElementById("pic2").src="icons/off2.jpg";
-
}
-
function two2(){
-
document.getElementById('pic1').src="icons/off1.jpg";
-
document.getElementById('aa').innerHTML = "<div style=visibility:hidden; display:none;>";
-
document.getElementById("bb").innerHTML = "<div style=visibility:visible; display:block;>";
-
document.getElementById("pic2").src="icons/on2.jpg";
-
}
-
</script>
-
<style type="text/css">
-
#aa { visibility:hidden; display:none;}
-
#bb { visibility:hidden; display:none;}
-
</style>
-
</head>
-
<body onLoad="start()";>
-
-
-
<div id="aa">
-
bla bla bla bla bla bla
-
</div>
-
<div id="bb">
-
da da da da da da da da da da da
-
</div>
-
-
-
<img id="pic1" src="icons/off1.jpg" width="50" height="50" onMouseOver="one1()"/><br />
-
<img id="pic2" src="icons/off2.jpg" width="50" height="50" onMouseOver="two2()"/><br />
-
</body>
-
</html>
-
Please help !!!!! i just need to find out how to change the style to invisibility:vi sible and display:block through the innerHTML!!!!
Thanks a million!!
Ricky
Ricky, try something like this
var obj=document.ge tElementById('I DOfYourObject')
obj.setAttribut e('align','righ t');
obj.setAttribut e('visibility', 'visible');
ohok thanks ill give it a shot!
still dosnt work :( thanks anyway
anyone?
Delerna 1,134
Recognized Expert Top Contributor
OK, then I think this is what you are trying to do
[HTML]<html>
<head>
<script type="text/javascript">
function start(){
document.getEle mentById('pic1' ).src="icons/on1.jpg";
document.all.aa .style.visibili ty = "visible";
document.all.bb .style.visibili ty = "hidden";
document.getEle mentById("pic2" ).src="icons/off2.jpg";
}
function one1(){
document.getEle mentById('pic1' ).src="icons/on1.jpg";
document.all.aa .style.visibili ty = "visible";
document.all.bb .style.visibili ty = "hidden";
document.getEle mentById("pic2" ).src="icons/off2.jpg";
}
function two2(){
document.getEle mentById('pic1' ).src="icons/off1.jpg";
document.all.bb .style.visibili ty = "visible";
document.all.aa .style.visibili ty = "hidden";
document.getEle mentById("pic2" ).src="icons/on2.jpg";
}
</script>
</head>
<body onLoad="start() ">
<img id="pic1" src="icons/off1.jpg" width="50" height="50" onMouseOver="on e1()"/><br />
<img id="pic2" src="icons/off2.jpg" width="50" height="50" onMouseOver="tw o2()"/><br />
<div id="aa">bla bla bla bla bla bla</div>
<div id="bb"> da da da da da da da da da da da</div>
</body>
</html>[/HTML]
WOWA thanks so much Delerna !!!!!!!!!!!
It works like a dream!!!!
Thanks heaps
Ricky
acoder 16,027
Recognized Expert Moderator MVP - function start(){
-
document.getElementById('pic1').src="icons/on1.jpg";
-
document.all.aa.style.visibility = "visible";
-
document.all.bb.style.visibility = "hidden";
-
document.getElementById("pic2").src="icons/off2.jpg";
-
}
That won't work in most browsers. Don't use document.all. Use document.getEle mentById instead, so your function becomes: - function start(){
-
document.getElementById('pic1').src="icons/on1.jpg";
-
document.getElementById("aa").style.visibility = "visible";
-
document.getElementById("bb").style.visibility = "hidden";
-
document.getElementById("pic2").src="icons/off2.jpg";
-
}
Delerna 1,134
Recognized Expert Top Contributor
Quite right, thanks acoder
in my job, everything i develop only ever gets used in IE so i am a bit weak and a bit lazy in that area
acoder 16,027
Recognized Expert Moderator MVP
No problem. It's never a bad habit to follow standards and then adjust for IE's bugs/quirks. It'll be useful when you're required to support more browsers.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Kerri |
last post by:
Sorry,
That was a typo. It should read.
I have a RequiredFieldValidator
This gets rendered out as a <span>
I want to set the innerHTML.
|
by: Soren Vejrum |
last post by:
I am working on a web-based html editor using MSIE's designmode and
iframes.
Everything works just fine, but MSIE changes all my relative "a href"
and "img src" links (i.e. "/index.asp") to absolute links (i.e.
"http://localhost/index.asp") when I set the iframe's innerHTML.
This is bad as the links are supposed to be relative. How can I avoid
this? Any solutions/suggestions are much appreciated.
|
by: C A Upsdell |
last post by:
I have a site where I am setting a style dynamically, using the JS
statement:
obj.style.backgroundImage = 'url(img/bak_page.jpg)';
where 'obj' is either document.getElementById(id), or document.all,
depending on browser support.
This works just fine, with just one small problem: I want to set the style
ONLY for screen media, not for printer media; the above statement appears to
|
by: RobG |
last post by:
I know you aren't supposed to use innerHTML to mess with table
structure, but it seems you can't use it just after a table without
damaging the containing element.
I added a table to a div using createElement methods, then added a bit
of extra text using innerHTML, only to find most of the attributes
removed from the table.
Below is a script that calls the same code to add a table inside a
div. It adds an onclick to the div and...
|
by: sagar |
last post by:
Hello everyone,
I am developing a AJAX based IM application. I use javascript to
dynamically generated small windows using nested <div> within the
web-page.
I use the following ways to set attributes & styles e.g.
.style.height=10; for styles
.setAttribute("id","outer") for attributes
| |
by: PJ |
last post by:
Greetings...
I have stumbled upon a small problem.
I use Ajax to retrieve part of a page I need to update. I update a DIV
element with the HTML contents I get from another page.
It works fine.
However the HTML have a SCRIPT tag that the browser should process, but
|
by: Mike |
last post by:
Hello,
I am trying to change the style(Position of an image) with a
function.This code worked a month ago and I dont know what I changed
I'm only showing the relevant code. One image is superimposed on
another.
--------------------------------------------------------------------
<script type="text/javascript">
function changenote(element) {
alert ("This Function is being Called");//Checking to see if the
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |