473,385 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Script to do a simulated popup window with divs

I am trying to find a javascript that will allow me to show and hide a named
div that is a just a styled window.

I don't want to open a window just show a div (that looks like a window)
then close it when the user clicks anywhere on the window. Maybe anywhere
on the screen but the popup but that is not necessary. Something simple.

The code I have is something like:

<div id="pnlPractitioners" class="popupControl">
<span id="dlResults"
style="font-weight:bold;text-decoration:underline;">Practitioners:</span>
<div class="prac">
<span id="Name">Peter J. Helton DO</span>
</div>
</div>

The css for popupControl is:

..popupControl
{
background-color: White;
position: absolute;
visibility: hidden;
border: solid 1px #000;
padding: 7px;
}

I originally tried to use Ajax to do this but it was gobbling up my onclick
event so I want to just do a quick open and close.

Thanks,

Tom
Jun 27 '08 #1
4 1920
I can almost get this to work.

I have an event that shows the Div and another that hides it.

I am trying set a timer for 10 seconds or until the user presses the
mousedown.

The problem is that now it goes directly to the HidePopup function instead
of waiting for the 10 seconds.

function ShowPopup(object)
{
var prefix =
object.id.substring(0,object.id.lastIndexOf("_")+1 );
var theObject = prefix + "pnlPractitioners"
var popup = document.getElementById(theObject);
var temp = popup.style;
var temp2 = temp.visibility;
temp.visibility = 'visible';

document.addEventListener("mousedown",HidePopup(th eObject),true);
setTimeout("HidePopup('" + theObject + "');",10000);

return;
}

function HidePopup(theObject)
{
document.removeEventListener("mousedown",HidePopup (theObject),true);
var popup = document.getElementById(theObject);
var temp = popup.style;
var temp2 = temp.visibility;
temp.visibility = 'hidden';
}

Am I missing something here?

Thanks,

Tom
"tshad" <tf*@dslextreme.comwrote in message
news:kS***************@fe097.usenetserver.com...
>I am trying to find a javascript that will allow me to show and hide a
named div that is a just a styled window.

I don't want to open a window just show a div (that looks like a window)
then close it when the user clicks anywhere on the window. Maybe anywhere
on the screen but the popup but that is not necessary. Something simple.

The code I have is something like:

<div id="pnlPractitioners" class="popupControl">
<span id="dlResults"
style="font-weight:bold;text-decoration:underline;">Practitioners:</span>
<div class="prac">
<span id="Name">Peter J. Helton DO</span>
</div>
</div>

The css for popupControl is:

.popupControl
{
background-color: White;
position: absolute;
visibility: hidden;
border: solid 1px #000;
padding: 7px;
}

I originally tried to use Ajax to do this but it was gobbling up my
onclick event so I want to just do a quick open and close.

Thanks,

Tom


Jun 27 '08 #2
On 16 May, 03:05, "tshad" <t...@dslextreme.comwrote:
I am trying to find a javascript that will allow me to show and hide a named
div that is a just a styled window.
How hard are you "trying"?

A google search for
popup divs
lists loads.

Here is one of my favourites:
http://www.dynamicdrive.com/dynamicindex11/abox2.htm
Jun 27 '08 #3
On May 16, 9:57 am, "tshad" wrote:
<snip>
The problem is that now it goes directly to the HidePopup function
instead of waiting for the 10 seconds.

function ShowPopup(object)
{
var prefix =
object.id.substring(0,object.id.lastIndexOf("_")+1 );
var theObject = prefix + "pnlPractitioners"
var popup = document.getElementById(theObject);
var temp = popup.style;
var temp2 = temp.visibility;
temp.visibility = 'visible';

document.addEventListener("mousedown",HidePopup(th eObject),true);
^^^^^^^^^^^^^^^^^^^
The - addEventListener - method is expecting a reference to a function
as its second argument but your - HidePopup - function does not return
a reference to a function (it returns the default - undefined -
value).

<snip>
Tom"tshad" wrote in message:
<snip>

Top-posting (and failing to suitably trim/edit quoted material) will
not encourage people to help you on Usenet.
Jun 27 '08 #4
tshad wrote:
I have an event that shows the Div and another that hides it.
You have an event _listener_ triggered by an event.
I am trying set a timer for 10 seconds or until the user presses the
mousedown.

The problem is that now it goes directly to the HidePopup function instead
of waiting for the 10 seconds.

[...]
document.addEventListener("mousedown",HidePopup(th eObject),true);
^^^^^^^^^^^^^^^^^^^^
setTimeout("HidePopup('" + theObject + "');",10000);
[...]

Am I missing something here?
You are calling the method before it is time to call it. You should change
the above into this at least:

var f = function(e) { HidePopup(theObject); };
document.addEventListener("mousedown", f, true);
window.setTimeout(f, 10000);

Are you sure you want an capturing event (`true'), which is incompatible to
the MSHTML DOM?

http://www.w3.org/TR/DOM-Level-2-Eve...ts-EventTarget

`HidePopup' should be `hidePopup' as it does not refer to a constructor.

All your method calls have to be feature-tested at runtime before:

http://www.jibbering.com/faq/faq_not...er_detect.html
Fewer spaces for indentation when posting would have been nice.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Jun 27 '08 #5

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

Similar topics

6
by: Mike Daniel | last post by:
I am attempting to use document.write(pageVar) that displays a new html page within a pop-up window and the popup is failing. Also note that pageVar is a complete HTML page containing other java...
11
by: Wentink | last post by:
Does anybody have a simple script that let's me popup a picture from a thumbnail? The ones i found are all very very complicated and messy in the source... Thanks, Tintin
2
by: Dennis | last post by:
This may be easy for most but I can't get this thing to work. I believe I followed all the instructions but when I click on the link no window opens just the default IE page cannot display. Here is...
24
by: jonathon | last post by:
Hi all, I have a web app with a popup window for entering data. I don't want to access the web every time this window is opened, as most of the app is AJAX. But I can't figure out how to open...
6
by: VK | last post by:
I'm using window.open method in my script to open poup window. Recently Internet Explorer users reported that the script crashes on their machine with different runtime errors. See the bug:...
4
by: Shawn Mason | last post by:
I have a requirment to utilize popup windows for edit/add screens from datagrids. I have accomplished this using client-side javascript. I have been told this is not acceptable and I must do it...
6
by: ruca | last post by:
Hi, Can I call two script blocks for different languages in my ASP.NET code? I have a button than when clicked it must open a popup window to return some values for two other controls that I...
2
by: Wolfman | last post by:
Hi guys I recently added a popup HREF script to a page, but I'd also like to make the page itself change when the HREF command is clicked. When the user clicks, not only would the popup window...
1
by: pandharinath | last post by:
I want to display fields(row) selected from grid in popup window to textboxes in Opener window. I have written code as follows : Main Opener window protected void Button1_Click(object...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.