473,769 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating popup using DOM and *no* html src


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 a new window and build it
with DOM rather than having to provide a src. Even a blank.html as src
takes time to fetch.

How can I create a popup and dynamically add DOM content without any
html at all?

Aug 10 '05
24 3264

Csaba Gabor skrev:
Gérard Talbot wrote:
Xandax wrote :
But the only other idea I would be able to think of is to actually make
the "popup" as content inside a div element which is hidden. Then on
some event you make it visible, and using z-index style you can then
position it above the other content.
<--snipped out for lenght --> I recommend against this route.

Csaba Gabor from Vienna


Well - as with everything, it can be abused.
But there are situations where such popups are justified, as well as
ordinary popups.
The reason that some mis-use popups due to advertisments, practically
hijacking ones browser, doesn't mean such an avenue couldn't/shouldn't
be explored.
It is fully depending on what the situation the OP is in whether or not
he should use such a "pseudo-popup" as descriped in my post.

I myself have used it in a project, when the user moves his mouse over
a specific icon, some information about the product in question is
shown. There it would be practically insane (in my view) to use
"ordinary" popups, or even shift the entier layout of the page to show
the notes somewhere "in-page".
Likewise there are many other situations where such a popup can be
useful, and perhaps even the optimal solution.

So is it with all technologies and techniques, that they can be
misused, but that shouldn't stop legitiment usage of them either.

-Xandax

Aug 12 '05 #11

Xandax wrote:
I am not familiar with ajax, so I don't know if this is a plausible
solution:

But the only other idea I would be able to think of is to actually make
the "popup" as content inside a div element which is hidden. Then on
some event you make it visible, and using z-index style you can then
position it above the other content.
This works great! It's a new iframe with an entry form. But I noticed
some odd behavior. In Firefox on Win32, there is a little shimmer, or
wiggle, when I move the mouse over the fields in the iframe. On
FreeBSD, the blinking cursor never appears in the fields. You can
edit, but you have to guess where the cursor is. I need to figure
these out.
I don't know if this is an acceptable avenue to venture down, but it
would be a possible way to mimic a "popup" without actually having to
supply an url for a window.open();


This isn't a popup in the advertising sense of the word. It's a
pseudo-dialog box that's part of the application. That's the AJAX way.

Aug 12 '05 #12
Xandax wrote:
Csaba Gabor skrev:
Gérard Talbot wrote:
Xandax wrote :
> But the only other idea I would be able to think of is to actually make
> the "popup" as content inside a div element which is hidden. Then on
> some event you make it visible, and using z-index style you can then
> position it above the other content.
<--snipped out for lenght -->
I recommend against this route.

Csaba Gabor from Vienna


Well - as with everything, it can be abused.


Such as quoting, for example. I don't have any issues with what you
wrote, but that quote from me above is incomplete and can be
misconstrued. My read of what the OP was asking for was a modal dialog
box (or at least a non modal one: a popup). And the OP expressed
succinctly the main issue: he can't pop up an empty one cross browser
and configure it. This is a heinous state of affairs and has bugged me
for years. But even so, for the reasons I gave in my prior post, >> in
general << I do recommend against them. And that in general means when
they are used to simulate another window (popup). It amounts to
whether one prefers the altered usability or whether one prefers to not
support certain browsers.

At the same time, let me repeat that I don't have issues with what you
wrote. Floating divs are extremely useful and I am using them quite a
bit. Everywhere from tool tips (because some browsers fall down on
providing multiline alt/title) to individual entries in family trees,
to heirarchical menus. But I don't think of a floating div as a popup.

Csaba Gabor
But there are situations where such popups are justified, as well as
ordinary popups.
The reason that some mis-use popups due to advertisments, practically
hijacking ones browser, doesn't mean such an avenue couldn't/shouldn't
be explored.
It is fully depending on what the situation the OP is in whether or not
he should use such a "pseudo-popup" as descriped in my post.

I myself have used it in a project, when the user moves his mouse over
a specific icon, some information about the product in question is
shown. There it would be practically insane (in my view) to use
"ordinary" popups, or even shift the entier layout of the page to show
the notes somewhere "in-page".
Likewise there are many other situations where such a popup can be
useful, and perhaps even the optimal solution.

So is it with all technologies and techniques, that they can be
misused, but that shouldn't stop legitiment usage of them either.

-Xandax


Aug 12 '05 #13

Csaba Gabor skrev:
Xandax wrote:
Csaba Gabor skrev:
Gérard Talbot wrote:
> Xandax wrote :
> > But the only other idea I would be able to think of is to actually make
> > the "popup" as content inside a div element which is hidden. Thenon
> > some event you make it visible, and using z-index style you can then
> > position it above the other content.

<--snipped out for lenght -->
I recommend against this route.

Csaba Gabor from Vienna


Well - as with everything, it can be abused.


Such as quoting, for example. I don't have any issues with what you
wrote, but that quote from me above is incomplete and can be
misconstrued. My read of what the OP was asking for was a modal dialog
box (or at least a non modal one: a popup). And the OP expressed
succinctly the main issue: he can't pop up an empty one cross browser
and configure it. This is a heinous state of affairs and has bugged me
for years. But even so, for the reasons I gave in my prior post, >> in
general << I do recommend against them. And that in general means when
they are used to simulate another window (popup). It amounts to
whether one prefers the altered usability or whether one prefers to not
support certain browsers.

At the same time, let me repeat that I don't have issues with what you
wrote. Floating divs are extremely useful and I am using them quite a
bit. Everywhere from tool tips (because some browsers fall down on
providing multiline alt/title) to individual entries in family trees,
to heirarchical menus. But I don't think of a floating div as a popup.

Csaba Gabor

Ahh - I'm sorry.
I misread your post. I hadn't noticed the link seperating the two
quotes and thought your answer was to my post, because I hadn't noticed
this seperation :o

I appologize :)

-Xandax

Aug 12 '05 #14
Matt Kruse wrote:
jonathon wrote:
How can I create a popup and dynamically add DOM content without any
html at all?


Unfortunately, you can't. When you open a window, it must have a url.

A work-around is to use the url of "about:blan k", but this causes security
warnings on secure sites, and doesn't work in some browsers. You can use a
javascript: pseudo-protocol to write out dummy content, but this also throws
up security warnings in some cases. You can leave a blank url, but only some
browsers prefer this over about:blank.

This is, IMO, unfortunate. There should be a cross-browser way to pop up a
new window and fill it with content without any security issues or problems.


Yes, this state of affairs has bugged me for years and it has gotten
worse. In particular, it is a perfectly reasonable thing to want to
have a modal dialog box, especially in light of the fact that more and
more we will be moving to internet based apps. And the OP is perfectly
reasonable in not wanting another hit to the server - that's a waste.
It's eminently clear that if javascript is running, then it could
pretty well do whatever it wants to on the original page so what's the
problem with letting it create and configure another page upon user
action?

I've done some experimenting and find FF to be in a pretty sorry state
on this point. The code below works fine on my (Win XP Pro) IE 6, but
FF has some major issues (not that the javascript console says even
Peep). If you run it with the alert line commented out, the button
won't get placed. With the alert line there, it will be place. But
this seems misguided at best, since the user has already clearly had to
take action to get this far - what purpose does clicking the errant
alert box serve?

<button id=btn1 accesskey=c
onclick="window .setTimeout('dl gShow()',10)">
<u>C</u>lick me</button>
<button accesskey=t
onclick="window .setTimeout('dl gShow()',10)">
<u>T</u>ry me</button>
<script type='text/javascript'>
function dlgShow() {
var nw=window.open( "javascript:'<h tml><head><titl e>" +
"Test</title><head><bo dy>should be a button here </body>'");

// alert("Alert needed for FF");

var btn = nw.document.cre ateElement("but ton");
btn.innerHTML = "Dialog <u>b</u>utton"
btn.accessKey = "b";
btn.onclick = function() {nw.alert("Dlg button clicked");}
nw.document.bod y.appendChild(b tn);

document.getEle mentById('btn1' ).onclick =
function() {window.setTime out('dlgShow()' ,10); }
}
</script>
Csaba Gabor from Vienna

Aug 12 '05 #15
Matt Kruse wrote :
Gérard Talbot wrote:
Unfortunatel y, you can't.


Well, I disagree. E.g.:
Create a sub-window and dynamically DOM-insert an image
http://www.gtalbot.org/DHTMLSection/...geInPopup.html

This example doesn't demonstrate your (incorrect) point.
It opens a file called "PopupWindowOnl yImage.html" when it does window.open.
It doesn't open a "blank" window with no contents.


You're right. It does not open a pure, virgin "about:blan k" document.
Updating via dynamically DOM-inserting an "about:blan k" can not be done
because of cross-domain security restrictions... but the
PopupWindowOnly Image.html document could be a blank document, could be a
blank window with no contents, not a pure "about:blan k" one though.
The current PopupWindowOnly Image.html contains only this:
<body onload="buildIm g();"></body>

so, I'd say it's pretty close to an empty document... It has script and
style etc...

Gérard
--
remove blah to email me
Aug 12 '05 #16
Csaba Gabor wrote :
Matt Kruse wrote:
jonathon wrote:
How can I create a popup and dynamically add DOM content without any
html at all?
Unfortunately , you can't. When you open a window, it must have a url.

A work-around is to use the url of "about:blan k", but this causes security
warnings on secure sites, and doesn't work in some browsers. You can use a
javascript: pseudo-protocol to write out dummy content, but this also throws
up security warnings in some cases. You can leave a blank url, but only some
browsers prefer this over about:blank.

This is, IMO, unfortunate. There should be a cross-browser way to pop up a
new window and fill it with content without any security issues or problems.

Yes, this state of affairs has bugged me for years and it has gotten
worse. In particular, it is a perfectly reasonable thing to want to
have a modal dialog box, especially in light of the fact that more and
more we will be moving to internet based apps. And the OP is perfectly
reasonable in not wanting another hit to the server - that's a waste.
It's eminently clear that if javascript is running, then it could
pretty well do whatever it wants to on the original page so what's the
problem with letting it create and configure another page upon user
action?

I've done some experimenting and find FF to be in a pretty sorry state
on this point. The code below works fine on my (Win XP Pro) IE 6, but
FF has some major issues (not that the javascript console says even
Peep). If you run it with the alert line commented out, the button
won't get placed. With the alert line there, it will be place. But
this seems misguided at best, since the user has already clearly had to
take action to get this far - what purpose does clicking the errant
alert box serve?

<button id=btn1 accesskey=c
onclick="window .setTimeout('dl gShow()',10)">
<u>C</u>lick me</button>
<button accesskey=t
onclick="window .setTimeout('dl gShow()',10)">
<u>T</u>ry me</button>
<script type='text/javascript'>
function dlgShow() {
var nw=window.open( "javascript:'<h tml><head><titl e>" +
"Test</title><head><bo dy>should be a button here </body>'");


This will trigger a validation error. Also, there is no need for
"javascript :" pseudo-protocol. Unless you're creating a bookmarklet, the
recourse to "javascript :" pseudo-protocol is always wrong, incorrect.
http://jibbering.com/faq/#FAQ4_24
http://developer.mozilla.org/en/docs.....29.22_....3E

// alert("Alert needed for FF");

var btn = nw.document.cre ateElement("but ton");
btn.innerHTML = "Dialog <u>b</u>utton"
Validation error here too: unescaped /
btn.accessKey = "b";
btn.onclick = function() {nw.alert("Dlg button clicked");}
nw.document.bod y.appendChild(b tn);

document.getEle mentById('btn1' ).onclick =
function() {window.setTime out('dlgShow()' ,10); }

I don't understand the purpose, reasons, justifications of setTimeout at
each of the 3 spots called in this code.

Gérard
--
remove blah to email me
Aug 12 '05 #17
Gérard Talbot wrote:
You're right. It does not open a pure, virgin "about:blan k" document.
Ummm, that _was_ the point, you know :)
Updating via dynamically DOM-inserting an "about:blan k" can not be
done because of cross-domain security restrictions...


That's not true either. You can popup an about:blank window and change it.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Aug 12 '05 #18
Gérard Talbot wrote:
Csaba Gabor wrote :

<script type='text/javascript'>
function dlgShow() {
var nw=window.open( "javascript:'<h tml><head><titl e>" +
"Test</title><head><bo dy>should be a button here </body>'");


This will trigger a validation error. Also, there is no need for
"javascript :" pseudo-protocol. Unless you're creating a bookmarklet, the
recourse to "javascript :" pseudo-protocol is always wrong, incorrect.
http://jibbering.com/faq/#FAQ4_24
http://developer.mozilla.org/en/docs.....29.22_....3E


Well, those two pages have NOTHING to do with the situation here.
Those pages say don't put href="javascrip t:..." within a link. This
situation has nothing to do with a link.
The fact that we're using window.open at all guarantees that javascript
is running, and the reason for using the javascript: is to return html
that is to be used as page content (as opposed to having a string url
which causes the browser to run out to the internet. That can mean a
potentially huge delay, which is what started this whole thread off)
// alert("Alert needed for FF");

var btn = nw.document.cre ateElement("but ton");
btn.innerHTML = "Dialog <u>b</u>utton"


Validation error here too: unescaped /


???
document.getEle mentById('btn1' ).onclick =
function() {window.setTime out('dlgShow()' ,10); }


I don't understand the purpose, reasons, justifications of setTimeout at
each of the 3 spots called in this code.


OK, this is a good point. I shouldn't have them there for the purposes
of this discussion (and I should only have one button). But here's why
they were there: If you put the alert back into the code, then the
button appears as you would expect. However, on my system (where I
embedded the whole page within a frame) using FF, I would get an
intermittent error (I can't consistently reproduce it else I'd have
already reported it to http://bugzilla.mozilla.org ) where after one
button press, the button would no longer fire if it tried to execute
the window.open. I tried putting in window.setTimeo uts just in case
(that why the first two were there), but that didn't work. The fix
that actually worked was to reset the handler to its original function
(which is why the third one was there - it's just a copy of the first
button's event handler). Thus, the second button still failed from
time to time.

Here's the code again, without the distracting setTimeout
Csaba Gabor
<button id=btn1 accesskey=c onclick="dlgSho w()">
<u>C</u>lick me</button>
<script type='text/javascript'>
function dlgShow() {
var nw=window.open( "javascript:'<h tml><head><titl e>" +
"Test</title><head><bo dy>should be a button here </body>'");

alert("Alert needed for FF"); // should not be needed

var btn = nw.document.cre ateElement("but ton");
btn.innerHTML = "Dialog <u>b</u>utton"
btn.accessKey = "b";
btn.onclick = function() {nw.alert("Dlg button clicked");}
nw.document.bod y.appendChild(b tn);
}
</script>

Aug 13 '05 #19
Csaba Gabor wrote :
Gérard Talbot wrote:
Csaba Gabor wrote :
<script type='text/javascript'>
function dlgShow() {
var nw=window.open( "javascript:'<h tml><head><titl e>" +
"Test</title><head><bo dy>should be a button here </body>'");
This will trigger a validation error. Also, there is no need for
"javascript :" pseudo-protocol. Unless you're creating a bookmarklet, the
recourse to "javascript :" pseudo-protocol is always wrong, incorrect.
http://jibbering.com/faq/#FAQ4_24
http://developer.mozilla.org/en/docs.....29.22_....3E

Well, those two pages have NOTHING to do with the situation here.
Those pages say don't put href="javascrip t:..." within a link. This
situation has nothing to do with a link.


Are you actually saying that you provided code which did not make use of
href="javascrip t:..." within a link?
// alert("Alert needed for FF");

var btn = nw.document.cre ateElement("but ton");
btn.innerHTML = "Dialog <u>b</u>utton"
Validation error here too: unescaped /

???


Unescaped forward slashes in a script will trigger validation errors by
the validator. That's what I meant.
document.getEle mentById('btn1' ).onclick =
function() {window.setTime out('dlgShow()' ,10); }


I don't understand the purpose, reasons, justifications of setTimeout at
each of the 3 spots called in this code.

OK, this is a good point. I shouldn't have them there for the purposes
of this discussion (and I should only have one button).


Thanks.

Gérard
--
remove blah to email me
Aug 14 '05 #20

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

Similar topics

5
3974
by: Obantec Support | last post by:
Hi i leached some code and strung together a popup i need for a page with 5 help buttons. Now i could use 5 scripts and pre-load the values but i would rather get a better understanding of how to pass some extra values to 1 script. 1. <SCRIPT LANGUAGE="Javascript"><!-- function popUp(url) {
38
5089
by: Shaun McKinnon | last post by:
HI...Here's my problem...I have a popup window that loads when i want it to, but it's not sized properly. I've set the size, but it doesn't seem to work. I've been on 8 different websites to find out what i'm doing wrong, and so far it seems i'm doing it the right way. Here's my code...any suggestions would be appreciated. <script language="javascript"> <!-- window.open("256fx/index.htm", "", "height=400, width=600"); //-->
12
12432
by: HarveyB | last post by:
I would like to generate non-modal popup windows from ASP.Net code-behind. I have tried using Client Side scripting like "function Test(){ window.open('test.htm',_blank, 'height=200,width=400,status=no,toolbar=no, menubar=no,location=no resizable=no scrollable=no'); but I can't seem to invoke the client side script from within a Server Side Form. I know I can use the context with to Response.redirect or Server.transfer to return a
2
1716
by: Logger | last post by:
Help! I’m trying to get popups to work in asp.net. I’m Using the following javascript code in a sub, but I can’t get the PopupWindow to work. At first I thought the routine wasn’t working but it is. It looks like it’s the window.open that’s not working. I have site popup allowed turned on, if I replace window.open with alert it works, if I put the code in the html code it works. Any suggestions? Dim PopupScript As String...
15
18744
by: | last post by:
So many websites can get around my Googlebar's popup blockers. Even Opera 8 can not stop those popups. I looked into the codes, and I can find nothing showing me how it is done. Can anyone help me find what how it is done? First go to http://www.sitepoint.com/forums/showthread.php?t=184025&page=1&pp=25 Click on Last ? on the page
15
2836
by: David Thielen | last post by:
Hi; My ASP.NET app (C# calling J# under .net 2.0) creates a png file in a subdirectory to display as part of the created page. However, the bitmap will not display due to a security violation. Everything is the default settings I believe. IIS is running under Local System. In IIS the DefaultAppPool is running under Network Service. Annonymous access uses the account IUSR_JASMINE (machine name is Jasmine).
1
5284
by: XP | last post by:
Hello Everyone, I was stuck with this really frustrating problem for sometime. Let me explain what I am trying to achieve: There is a form and an inner iframe. The form's target is set to the iframe so that when the form is submitted, the page does not get reloaded/changed ( as the iframe would be the one getting refreshed. The Iframe is set to have 0 width and height to make it look invisible ). I have a copied the html source ( at...
2
3267
by: wreed06 | last post by:
Hello, I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully validated my HTML and CSS code. 1. When I clear cache and refresh my webpage, it takes 3 tries before the popup window displays - I click on the button once, a white window the size of my webpage displays. I close it and click on the button again (for...
11
5321
by: V S Rawat | last post by:
using Javascript, I am opening a web-based url in a popup window. MyWin1=Window.Open(url, "mywindow") There is a form (form1) in the url in that popup window, I need to submit that form. How do I submit that form1 from the javascript from my current window? Thanks.
0
9590
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
9424
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
10000
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
9866
tracyyun
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...
0
6675
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
5310
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...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3968
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
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.