/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Modal windows

After a search it sure seems that something as simple as a modal popup should not be so hard.

My function

[CODE]unction modalWindow(w_url)
{
var str_windowproperties=”dialogwidth=350,dialogHeight=150,center=yes,edge=raised,resizeable=no,help=no,status=no”;
var answer = window.showModalDialog(w_url, str_windowproperties);
}[/CODE]

Basically I am calling a simple popup so the user can copy the URL to the page (perma Link) then close the window and be on their way.

I have look at the light box and other stuff and I know this can be done with all that extra code.

It seems to work fine as I do get a modal window ( I cannot click on anything else until I close the window). But [B]I cannot get the window size to work[/B]. It is different in FF and IE. Both of my browsers are up to date.

Do I need to set the size of the window in the actual page?.

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@opifexOct 18.2009 — can you give a link?
Copy linkTweet thisAlerts:
@rnd_meOct 18.2009 — your formatting is off:

example of correct syntax:
[CODE]"resizable: yes; center: on; dialogwidth: 273;"[/CODE]

i don't know what you call this format, it looks like a mutant of json and encoded form pairs, but it works.
Copy linkTweet thisAlerts:
@DawgauthorOct 18.2009 — Thank you very much.

I knew it was something stupid I was doing.
Copy linkTweet thisAlerts:
@DawgauthorOct 18.2009 — Perhaps I resolved this too soon. It worked in FF just fine if I used the height and width set in the script. In IE it waas the right width but no the height.

Now I am trying to send the height and width variables over to the script and in both IE and FF it does not get set to a proper width.

Am I doing something wrong with the variables or in the property declaration??

Thanks

Here is the Script code:
[CODE]function modalWindow(w_url, w_width, w_height)
{
var int_windowLeft = (screen.width - w_width) / 2;
var int_windowTop = (screen.height - w_height) / 2;

var str_windowproperties="dialogWidth:w_width; dialogHeight:w_height; dialogTop:int_windowTop; dialogLeft:int_windowLeft; edge:raised; resizeable:no; help:no; status:no";

var answer = window.showModalDialog(w_url, str_windowproperties);
}[/CODE]


Here is the script call, quotes are escaped for PHP insertion.
[CODE]<a href="javascript:var w_open=modalWindow('a_link.php?a=$url_link', 425, 125)">Perma Link</a>[/CODE]

Here is a link to try it.

http://www.sailinganarchy.com/z_article.php?get=1557
Copy linkTweet thisAlerts:
@rnd_meOct 19.2009 — 

Am I doing something wrong with the variables or in the property declaration??
[/QUOTE]



w_width is not a number, it stuck in the string.

you need something like:[CODE]
var str_windowproperties="dialogWidth:"+w_width+"; dialogH...[/CODE]
Copy linkTweet thisAlerts:
@DawgauthorOct 19.2009 — Thanks rnd_me I changed the code to:

[CODE]function modalWindow(w_url, w_width, w_height)
{
var int_windowLeft = (screen.width - w_width) / 2;
var int_windowTop = (screen.height - w_height) / 2;

var str_windowproperties="dialogWidth:"+w_width+"; dialogHeight:"+w_height+"; dialogTop:int_windowTop; dialogLeft:int_windowLeft; edge:raised; resizeable:no; help:no; status:no";

var answer = window.showModalDialog(w_url, str_windowproperties);
}[/CODE]


But it did not seem to work either. I deleted all my cache too just tom make sure I was not getting a bad copy.
Copy linkTweet thisAlerts:
@DawgauthorOct 21.2009 — I give up, I can't even make a stupid pop up work ?
×

Success!

Help @Dawg spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...