...

View Full Version : HELP with modal window



mcoelho123
08-04-2006, 05:32 PM
Hi guys,

i have this in a page:


function show_habit() {
self.name = "Parent_Window";
if (document.all)
window.showModalDialog("programas/habitacoes.php","","dialogWidth:780px;dialogHeight:500px")
else {
alert("You need IE")
}
}
<a onClick="show_habit()">Test</a>


And in the modal window


<base target="Parent_Window">

function set_link(id) {
switch (id) {
case "1":
a = "http://www.google.com";
break;
}
return a;
}
<a href="" onclick="return set_link('1')">google</a>


But it dont work and no error occurs. The modal page opens but inside it when i click "google" it goes to the folder where the html page is instead of http://www.google.com.
Can anyone help me in this one?? Thanks

felgall
08-05-2006, 12:40 AM
That code will crash Opera.

document.all does not identify support for window.showModalDialog

document.all identifies that the browser is IE or Opera (or some other more obscure browser that also happens to recognise it.

To test for window.showModalDialog support test like this:

if (window.showModalDialog)
window.showModalDialog("programas/habitacoes.php","","dialogWidth:780px;dialogHeight:500px")
else {
alert("I am using intranet only code on the internet so it doesn't work in your browser")

mic2100
08-05-2006, 09:05 AM
i think that this will maybe work, when i tested it the link it displayed the localsite in the IE status but upon clicking the link you are directed to google.



<base target="Parent_Window">
<script language="javascript">

function set_link(id, linkID)
{

switch (id)
{

case "1":

a = "http://www.google.com";

break;

}

document.getElementById(linkID).href = a;

}
</script>
<body>
<a id='linkID1' onClick="set_link('1', 'linkID1')" href='' target="_blank">Google</a>
</body>


I hope this works for you.

glenngv
08-06-2006, 02:12 AM
function set_link(link, id) {
var a;
switch (id) {
case "1":
a = "http://www.google.com";
break;
//...
}
link.href = a;
return true;
}
...
<a href="#" onclick="return set_link(this, '1')">google</a>
But why not just hardcode the href of each link if the function will simply change the href and nothing more?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum