Congratulations to AcaCandy on her 100,000th post!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen boot bsod computer connection crash css dell driver drivers email error ethernet excel firefox firefox 3 hard drive internet internet explorer itunes laptop linux malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express partition password printer problem router security slow software sound trojan usb video virus vista wifi windows windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Alternative to ShowModalDialog for Netscape?


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
lonesome_wolf2000's Avatar
Senior Member with 410 posts.
 
Join Date: Dec 2000
03-Mar-2005, 05:59 PM #1
Alternative to ShowModalDialog for Netscape?
Hey everyone,

I've been trying to find some better way of popping up images on the site im making. I have been using this method:

<a href="#" onClick="window.showModalDialog('jpg/pic.jpg','','dialogWidth:526px;dialogHeight:404px'); return false

The only problem is Netscape, Firefox, and pretty much anything other than IE won't display this box. Does anyone have a better way of doing this? I tried the window.open method and it works, but the box isn't as neat as this. I can never get it completely flush against the image.

Thanks in advance.
Shadow2531's Avatar
Distinguished Member with 2,629 posts.
 
Join Date: Apr 2001
04-Mar-2005, 05:46 AM #2
Just make your own div-popup.

Code:
<script type="text/javascript">
    function rm() {
        document.body.removeChild(document.getElementById("modal"));
    }
    function showModalDialog(pic,w,h) {
        
        var d = document.createElement("div");
        d.style.position = "absolute";
        d.style.backgroundColor = "#fff";
        d.style.left = "25%";
        d.style.top = "15%";
        d.style.width = w + "px";
        d.style.height = h + 20 + "px";
        d.style.border = "2px solid #000000";
        d.style.textAlign = "right";
        d.id = "modal";
        
        var i = document.createElement("img");
        i.src = pic;
        i.style.width = w + "px";
        i.style.height = h + "px";
        
        var l = document.createElement("a");
        l.href = 'javascript:rm()';
        l.appendChild(document.createTextNode("X"));
        l.style.position = "absolute";
        l.style.right = "8px";
        l.style.top = "5px";
        l.style.color = "#000";
        l.style.textDecoration = "none";
        
        d.appendChild(i);
        d.appendChild(l);
        
        document.body.appendChild(d);
    }
</script>

<a href="#" onclick="showModalDialog('zipped.gif',526,404); return false">show</a>
The div is not moveable like a window, but it can be made to move with some extra work.

The width and height specified in the event call are to specify what size you want the image to be displayed at. The div size is relative to the image size with a little extra space on the bottom.

Adjust the script as needed.
__________________
10 ? "a line as the unending horizon"
20 ? "a curve as the rolling hillside"
30 ? "a point as a distant bird"
40 ? "a ray as the rising sun"
run

Last edited by Shadow2531 : 04-Mar-2005 05:51 AM.
lonesome_wolf2000's Avatar
Senior Member with 410 posts.
 
Join Date: Dec 2000
05-Mar-2005, 11:58 AM #3
Hmm...

Interesting.

Thanks for the info... I'll see what I can do and try to tweak this to what I'm looking for. Really cool! Thanks a bunch. I was never really that good with making things like this...

thanks again
lonodev's Avatar
Junior Member with 2 posts.
 
Join Date: Mar 2005
Experience: Intermediate
12-Mar-2005, 08:56 PM #4
I am creating a new window by using HTML instead of calling a page from the server.Now,I would like to make this new window modal.I thought of using showmodaldialog available in IE but we can't tell it to open an empty url like in window.open.

Example we cannot do window.showmodaldialog("")
But I can do window.open("") and then use the document.writeln to do my html for this new window,but this is not a modal window.
So I looked at the above piece of code thought I could tweak it to tell it as modal window.Could you give me a quick explanation of the above piece of code does so that I can use it to make my new window modal.

Appreciate your help.

Thanks.
Shadow2531's Avatar
Distinguished Member with 2,629 posts.
 
Join Date: Apr 2001
13-Mar-2005, 05:57 AM #5
The code just builds a div element with the img code, and X link insided it.

When you click on the link, it just adds the div to the document. When you click the X, it just removes the div from the document.

The div appears on top because it has position:absolute set for it.

The size of the div and image are determined by the values you pass to the function as you'll see in the link.

The left and top position set for the div determine where the div will popup at on the screen.

The properties set for the elements in the code are css properties.

Basically it creates

Code:
<div id="modal" width="" height="">
    <img src="" width="" height="" />
    <a href="javascript:rm()">X</a>
</div>
The x link has an absolute position inside the div.

The values for the width, height and src attributes are determined by what values are passed to the function by the 'show' link.
__________________
10 ? "a line as the unending horizon"
20 ? "a curve as the rolling hillside"
30 ? "a point as a distant bird"
40 ? "a ray as the rising sun"
run

Last edited by Shadow2531 : 13-Mar-2005 06:38 AM.
lonodev's Avatar
Junior Member with 2 posts.
 
Join Date: Mar 2005
Experience: Intermediate
13-Mar-2005, 08:49 PM #6
Thanks for the explanation.Let me explain little more..what I am trying to do and then may be you can help me.
I am creating and opening a new pop window using HTML in JavaScript so there is no page on the server that has to be fetched to display the pop up.Now I would like to set the new pop window that was created to be a modal.I cannot use the showModaldialog function..as I have to sepcify a page to load.
I need a way to tell the browser to open the new pop window that was dynamically created as modal.
Can you help me?

Appreciate your help.

Thanks.
Shadow2531's Avatar
Distinguished Member with 2,629 posts.
 
Join Date: Apr 2001
14-Mar-2005, 08:08 AM #7
You can only create modal windows in IE.

So all you can do is write() stuff to the window like this.

Code:
var w = window.open("","popup");
w.document.write('<a href="javscript:this.window.close()">close this window</a>');
which you have already done. You can of course control the size of the window that pops up. (If the browser settings allow it)

Now if you want to build the html and append to the window document, you can, but it'll only work in Firefox.

So basically, write the html to the window like you are doing and just have a this.window.close() link.

Of course that's repetitive because the person can just close the window without the link.

If you want to avoid all that, write the popup div to the current document like shown above.

Not sure of any other ways to do it.
__________________
10 ? "a line as the unending horizon"
20 ? "a curve as the rolling hillside"
30 ? "a point as a distant bird"
40 ? "a ray as the rising sun"
run
Shadow2531's Avatar
Distinguished Member with 2,629 posts.
 
Join Date: Apr 2001
15-Mar-2005, 03:35 PM #8
The window.open method should be fine, if you do it like this:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-us" xml:lang="en-us">
    <head>
        <title>Popup</title>
        <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
        <meta http-equiv="content-style-type" content="text/css"/>
        <meta http-equiv="content-script-type" content="application/x-javascript"/>
        <meta http-equiv="content-language" content="en-us"/>
        <script type="text/javascript">
        //<![CDATA[

        function popup() {

          var w = window.open("","_blank","left=200,top=200,width=300,height=130");
              w.document.write('<html><title>popup</title><body><div>')
              w.document.write('<img src="http://www.google.com/intl/en/images/logo.gif" alt=""/>');
              w.document.write('</div></body></html>');
              w.document.close();
              w.focus();
         }

        //]]>
        </script>
    </head>
    <body>
        <div><a href="javascript:void(popup())">popup</a></div>
    </body>
</html>
nonane's Avatar
Junior Member with 26 posts.
 
Join Date: Mar 2005
Location: Lexington, SC
Experience: Advanced
18-Mar-2005, 03:55 PM #9
Couldn't you do a "onLostFocus" or "onBlur" event to execute w.top.focus(); and force you to keep that window on top?
Shadow2531's Avatar
Distinguished Member with 2,629 posts.
 
Join Date: Apr 2001
18-Mar-2005, 07:02 PM #10
You can use the onblur event to automatically switch focus right back to the window.

Last edited by Shadow2531 : 18-Mar-2005 07:11 PM.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 06:15 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.