473,625 Members | 3,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reaching an html span nested in an html div with javascript

Hi;

I'm working on a demo of using a timer on a web site that is made
visible by making a div visible.

My "PopIn Box" div is empty on the page. Before making it visible I
used javascript to get the content from another hidden div. I'm
doing it this way to make it easier to add in more messages by simply
putting more hidden divs on the page.

My timer function showtime(), at the end, writes the countdown into
the status bar and into the span called "clock" which is inside a
hidden div "content".

This works great in IE 7 and in the latest Firefox. It does not work
for Opera or Safari for windows. These browsers can't seem to reach
the span nested in the div, moving the content around between divs as
I am.

Any ideas why or suggestions for a work around. My sample HTML file
is below the "========" so anyone who wants to take a look can paste
it into a file to play with it.

Thanks much in advance

=============== =============== ============
<html>
<head>
<title>Demo: Javascript Timer & Divs </title>
<style type="text/css" type="">

<!-- For IE, we need the width and height of the body set this way
here -->
body
{
height: 100%;
margin: 0;
padding: 0;
width: 100%;
background-color:#d3d3d3;
filter:alpha(op acity=100);
-moz-opacity:1;
-khtml-opacity:1;
opacity:1;
}
.popin
{
display:none;
height:50%;
width:50%;
position:absolu te;
top:25%;
left:25%;
background:whit e;
color:black;
padding:1%;
border: 16px solid black;
z-index:1002;
filter:alpha(op acity=100);
-moz-opacity:1;
-khtml-opacity:1;
opacity:1;

}
</style>
<script language = "javascript ">
// Creat a new Date object called minutes.
var startpoint = new Date();

// Ad 20 minutes to whatever the minutes in the current hour is
// this is the time in the future when the session ends
startpoint.setM inutes(startpoi nt.getMinutes() + 20);

//-----------------------------------------------------------------------------
// This function is called whever the page is loaded
// Update the status bar with the time left in the session once per
second AND
// Update the hidden form var once per second with the time left
function showtime()
{
// Make a new date object to be "right now"
var now = new Date();

// Subtract the time when the page loaded ( + 20 min ) - the time
now
// this is the time left int he session
var tDiff = startpoint.getT ime() - now.getTime();

//alert("showTime (): " + document.TimerF orm.timeSetter. value);
if(document.Tim erForm.timeSett er.value != '')
{
startpoint = new Date();
startpoint.setM inutes(startpoi nt.getMinutes() + 20);
tDiff = startpoint.getT ime() - now.getTime();

alert(startpoin t.getTime() + " - " + now.getTime() + " = " +
tDiff);
document.TimerF orm.timeSetter. value = '';
}

// Set "now" to be the time left in the session
now.setTime(tDi ff);

// Put the time left in the session into the hidden form field.
// Format it to be "minutes:second s". Use the ? short hand
conditional
// to insert a zerio in front of minuets or seconds readings that
are less
// than two digits

document.TimerF orm.sysTimer.va lue = '' +
(now.getMinutes ()<10 ? '0' + now.getMinutes( ):now.getMinute s()) +
':'+
(now.getSeconds ()<10 ? '0' +
now.getSeconds( ):now.getSecond s());

var statusString = "Remaining Session Time : " +
document.TimerF orm.sysTimer.va lue;

statusbar = statusString;
showtimeInClock ();

setTimeout('sho wtime()',1000);

}

//------------------------------------------------------------------------------
// Output time to the span in the div
function showtimeInClock ()
{

var divClock = document.getEle mentById("clock ");
divClock.innerH TML = document.TimerF orm.sysTimer.va lue;
}

//-----------------------------------------------------------------------------
function showPopIn()
{
var pop_in = document.getEle mentById("divPo pIn");
var content = document.getEle mentById("conte nt");
pop_in.innerHTM L = content.innerHT ML;

pop_in.style.di splay = "block";
}

//----------------------------------------------------------------------------
function stopPopIn()
{
var pop_in = document.getEle mentById("divPo pIn");
pop_in.style.di splay = "none";
}

//-----------------------------------------------------------------------------
</script>
</head>
<body>

<p align = "center">
Javascript Timer
</p>

<form name = "TimerForm" action = "">
<input type = "hidden" name = "sysTimer" value = 0>
<input type = "hidden" name = "timeSetter " value = "">
</form>

<!-- The "PopIn" box with the timer in it -->
<div id="divPopIn" class = "popin"></div>

<!-- Content to put in the "PopIn" box -->
<div id="content" style = "display:none;" >
<p style = "text-align:center;fo nt-size:150% !important;font-
weight:bold;col or:red;">
<u>Count Down:</uin
<span id = "clock" style = "position:cente r;padding-right:
4px;">
</span>
(min:sec)
<p>
</div>

<script>
// Continually update the time read out in the Pop-In & status bar
showtime(); ;
</script>

<br>
<br>
<a href = "javascript:sho wPopIn();">Run Timer Display</a>
<br>
<br>
<a href = "javascript:sto pPopIn();">Stop Timer Display ()</a>
<br>

</body>
</html>
Jun 27 '08 #1
1 2854
On Apr 18, 9:59 am, Steve <tinker...@gmai l.comwrote:
Hi;

I'm working on a demo of using a timer on a web site that is made
visible by making a div visible.

My "PopIn Box" div is empty on the page. Before making it visible I
used javascript to get the content from another hidden div. I'm
doing it this way to make it easier to add in more messages by simply
putting more hidden divs on the page.

My timer function showtime(), at the end, writes the countdown into
the status bar and into the span called "clock" which is inside a
hidden div "content".

This works great in IE 7 and in the latest Firefox. It does not work
for Opera or Safari for windows. These browsers can't seem to reach
the span nested in the div, moving the content around between divs as
I am.
I got a clue. I changed the file to use just one div. Then I took
the position:absolu te; out of the style class for that div and it
seemed to work.

Any ideas why and how I can keep that attribute or achieve the same
result?
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2073
by: ALuPin | last post by:
Hi newsgroup users, I have the following java-script: </SCRIPT> </head> <body text='' link='' vlink='' alink='' bgcolor='FFFFFF'> <p> <center><TABLE cellSpacing=1 cellPadding=1 width="60%" align=center border=0>
2
4336
by: KathyB | last post by:
Hi, I have the following script in an aspx html: <script language="javascript"> function pop_window() { var confirmWin = null; confirmWin = window.open('Scanned.aspx', 'SerialNumbers', 'width=300,height=400,left=200,top=200,toolbar=no,resizable=no,menubar=no'); } </script>
9
1547
by: Jason Gogela | last post by:
Does anyone out there know why I should care whether a <span> is nested in a <p> or vice versa? What is the bennafit of adhering to this standard? It seems to me that regardless of which way you write it, the page will render the same, sans errors, in any browser. All responces will be greatly appreciated. ~Jason Gogela
12
2251
by: Nalaka | last post by:
Hi, I suddenly started getting a lot of errors from html validation (some CSS) so I followed the following instructions to disable it. If you'd rather not have these types of HTML validation errors show up in your error-list, you can disable this functionality by selecting the Tools->Options menu item in VS or Visual Web Developer. Select the TextEditor->Html->Validation tree option in the left-hand side of the
3
3252
by: amit | last post by:
Hello group, How can I assign a link with its related elements (as following) to an array element? Assume having a table with several rows and 3 columns. The first column holding some text information (which will be read from a database) but the 2nd column holding a link (as its previous rows - now I'm adding a new row).
1
16949
by: since | last post by:
I figured I would post my solution to the following. Resizable column tables. Search and replace values in a table. (IE only) Scrollable tables. Sortable tables. It is based on a lot examples I found on the web. Works in IE and mozilla. http://www.imaputz.com/cssStuff/bigFourVersion.html
3
1696
by: Steve | last post by:
Hi; I'm working on a demo of using a timer on a web site that is made visible by making a div visible. My "PopIn Box" div is empty on the page. Before making it visible I used javascript to get the content from another hidden div. I'm doing it this way to make it easier to add in more messages by simply putting more hidden divs on the page.
7
3603
by: imtmub | last post by:
I have a page, Head tag Contains many Scripts and style sheet for Menu and Page. This code working fine and displaying menus and page as i wanted. Check this page for reference. http://www.marco.com.cn/web-content/marco_re10.html -------------------------------------------------------------- <head> <!-- InstanceBeginEditable name="doctitle" --> <title>Marco</title> <!-- InstanceEndEditable -->
10
7371
by: dkyadav80 | last post by:
<html> /// here what shoud be java script for: ->when script run then not display all input text field only display selection field. ->when user select other value for institute only this field display not display degree text field ->when user select other value in the selection field for degree then text field display and wise versa //// <bodly> <table>
0
7133
by: studentofknowledge | last post by:
hi my knowledgeable comrads I have created a web form using html, css with the addition of some basic javascript validation. Although now im having trouble to insert this information to my local SQL database - can someone point me in the right direction please or refer me to a good example/pre written code? I am using Vista Business operating system in conjunction with SQL server 2005 express edition, SQL server service pack 2, SQL server...
0
8259
marktang
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...
0
8192
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,...
1
8358
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,...
0
7188
agi2029
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...
0
5571
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();...
0
4090
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...
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1504
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.