Solved

open jquery dialog with php / open javascript function with php

Posted on 2010-09-16
4
1,107 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
jrm213jrm213 earned 500 total points
ID: 33692270
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
ID: 33692408
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
ID: 33692544
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
ID: 33692652
Thanks JRM, your first post was actually working!

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

Thank you very much!
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

717 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