Solved

open jquery dialog with php / open javascript function with php

Posted on 2010-09-16
4
1,096 Views
Last Modified: 2012-05-10
Hi!

i want a piece of php code to check what type of browser someone is using and make a jquery dialog open if they use MIE.

The dialog works, the php browser check-code works, but i cant get the php-code to open the jQuery dialog window..
What am i doing wrong?

here are the codes i'm using:

thanks!
BROWSER CHECK AND OPEN DIALOG:

<?  
ini_set('display_errors', 'On');
error_reporting(E_ALL);

    if (isset($_SERVER['HTTP_USER_AGENT']) && 
    (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))
       echo "<script type=\"text/javascript\">IEuser();</script>";
    else
        echo "Yes, you're not using IE!<br><br>";
?>

Open in new window

OPEN DIALOG:

<script type="text/javascript">
function IEuser() { 
        $('#dialog').dialog('open');
};
</script>

Open in new window

0
Comment
Question by:peps03
  • 2
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
jrm213jrm213 earned 500 total points
Comment Utility
It might be calling it before everything is loaded,

try the following snippet:


<?  
ini_set('display_errors', 'On');
error_reporting(E_ALL);

    if (isset($_SERVER['HTTP_USER_AGENT']) && 
    (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))
       echo "<script type=\"text/javascript\">$(document).ready(function (){IEuser();});</script>";
    else
        echo "Yes, you're not using IE!<br><br>";
?>

Open in new window

0
 

Author Comment

by:peps03
Comment Utility
thanks for your reply jrm!

it isn't opening the dialog. instead, i get this error from ie:

Message: Object expected
Line: 65 ===<script type="text/javascript">$(document).ready(function (){IEuser();});</script>
Char: 31
Code: 0
URI: http://localhost/pepijnniesten.nl/index2.php


0
 
LVL 17

Expert Comment

by:jrm213jrm213
Comment Utility
Is it all versions of IE or just IE6?
Try removing the "type" from your <script> tags, especially for including jquery.

<script language=”javascript” src=”your-path-to-jquery-version.js”></script>
0
 

Author Comment

by:peps03
Comment Utility
Thanks JRM, your first post was actually working!

I had a typo in my javascript function.. "IEuser"

Thank you very much!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now