To anyone who’ll experience similar issue in future:
In the end, I decided that having form as a pop-up is not worth so much effort for IE users (I realise it’s more than half of users but for now, I’m OK when the form opens and users of standards compliant browsers will benefit of better layout
)
Here’s the summary:
- I needed the form to be accessible for everyone
- I wanted it to be small pop-up (it has only few lines, namely Name, Email, Message, Submit, so it wouldn’t look well in full-size browser window)
Function I used is:
<script type="text/javascript">
function mailto_form() {
window.open( "mailto_form.html", "myWindow",
"status = 1, height = 335, width = 300, resizable = 0" )
}
</script>
Here is the event I used to call the function:
<a href="#" onClick="(mailto_form())">Contact Us</a>
Everything worked fine if you use anything else than IE (not sure about ‘anything’ but tested in Chrome, FF, Opera and Safari). IE wouldn’t call function mailto_form(), just the href="#".
After hours trying to figure out, what’s wrong, I decided to try different approach. Keep everything same and modify just if the user is IE users. Initially I tried to define the link calling the mailto_form() function as:
<a href="mailto_form.html" onClick="(mailto_form()); return false">Contact Us</a>
I called the link directly and result - every browser opened it in same window… I had to change the approach:
I defined variable $mailto_popup this way:
[php]<?php
$browser = $_SERVER[‘HTTP_USER_AGENT’];
if(preg_match(’/MSIE/i’,$browser))
{
$mailto_popup = “mailto_form.html”;
}
else{
$mailto_popup = “#”;
}
?>
[/php]
so for IE users it will contain link, for others just #.
Then I used $mailto_popup variable in the link calling function mailto_form() this way:
[php]Contact Us[/php]
The result is:
If the visitor uses IE, link will open mailto_form.html in same browser window (far too huge for small form but whatever - important is that it works
). If the visitor doesn’t use IE, the same form will be opened as a small (and much better looking) pop-up.
I realise this is not best solution but it works everywhere. I plan to add variable to the link and display the page with some sort of warning for IE users.
Hope this might help someone else in future