Darksat IT Security Forums
December 13, 2017, 05:05:46 am
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Darksat IT Security Forum
From Firewall Support, AntiVirus Questions, Spyware problems, Linux and Windows Security, Black Hat SEO right down to Website Design and Multimedia
 
  Home Help Search Gallery Links Staff List Login Register  

Lightbox innerHTML


Pages: [1]
  Print  
Author Topic: Lightbox innerHTML  (Read 2374 times)
Defcon 5
Master
*****
Posts: 2410



View Profile WWW
« on: April 05, 2009, 10:40:36 am »

Code:
if(document.getElementById('lightbox')!='null'){
alert("1");
body = document.getElementsByTagName('body')[0];
body.innerHTML='<div id="lightbox" class="hide">&nbsp;</div>'+body.innerHTML+'';
}
Okay so id lightbox is just showing a greyed out overlay with 50% opacity, and class hide is display:none;.
I get the alert of 1 everytime the function is used.

So problem I'm having is this is called on loading the lightbox functon, but then I cannot hide the lightbox again using this:
Code:
document.getElementById('lightbox').style.display="none";
How can I put the lightbox div in using javascript and having it editable with the javascript?
Report Spam   Logged

Social Buttons

Darksat
Administrator
Master
*******
Posts: 3303



View Profile WWW
« Reply #1 on: April 08, 2009, 08:21:47 pm »

Mate its 3AM in the morning so perhaps im having a brain fart, but tht code looks a little messed up.
body.innerHTML is very iffy if I remember correctly.
especially if your loading anything from inside the body tag.
Anyway show me a demo page nd I will take a look.
Report Spam   Logged
Defcon 5
Master
*****
Posts: 2410



View Profile WWW
« Reply #2 on: April 09, 2009, 11:43:31 am »

It was all locally, but idea was to just link a external JS file without having to add any div's for the actual lightbox.

I've given up, it pissed me off  Tongue
Report Spam   Logged
Darksat
Administrator
Master
*******
Posts: 3303



View Profile WWW
« Reply #3 on: April 09, 2009, 02:07:30 pm »

As far as I remember some browsrs have problems implementing body.innerHTML, something about the paths.
You can do something uber simple like this very easily
Code:
<html><head><title>Darksat Box</title>
<SCRIPT LANGUAGE="javascript">
function go() {
if (light.style.visibility == "visible")
{
light.style.visibility = "hidden";
}
else
{
light.style.visibility = "visible";
}
}
</SCRIPT>

</head>
<body>
<INPUT TYPE="button" VALUE="show/hide" onClick="go();">
<SPAN ID="light" Style="Visibility:visible;">
<h1>Content</h1>
</SPAN>

</body>
</html>

Or check out another solution here.
http://www.emanueleferonato.com/downloads/lightbox.html
« Last Edit: April 09, 2009, 02:10:35 pm by Darksat » Report Spam   Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
eXTReMe Tracker
Security Forum
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Buy traffic for your forum/website
traffic-masters
Powered by SMF | SMF © 2016, Simple Machines
Page created in 0.109 seconds with 11 queries.