Solved

Need to change an objects property..

Posted on 2008-06-19
7
199 Views
Last Modified: 2013-11-05
I'm using phpsniff to find the browser's properties.  If the browser is IE6 or less, I want to make an image visible.  Below is the HTML code that describes the image; I want to change the object GrLabel2's visibility to true if a condition is met (all this done in PHP).

How do I do this?

<body text="#000000" bgcolor="#FFFFFF" link="#0000FF" alink="#FF0000" vlink="#800080">

<div id="ldheGrLabel2" style="position: absolute; left: 359px; top: 113px; visibility: hidden;" align="left">

<img id="GrLabel2" name="GrLabel2" src="Images/sandbox-2_grlabel2.png" width="220" height="16" border="0" alt=""></div>

<div id="ldheHtml1" style="position: absolute; left: 48px; top: 220px; width: 147px; height: 89px;" align="left">

Open in new window

0
Comment
Question by:rmmarsh
  • 4
  • 3
7 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 21825375
<div id="ldheGrLabel2" style="position: absolute; left: 359px; top: 113px; visibility: <?php echo $client->browser_is('IE6') ? 'visible' : 'hidden'; ?>;" align="left">
<img id="GrLabel2" name="GrLabel2" src="Images/sandbox-2_grlabel2.png" width="220" height="16" border="0" alt=""></div>
0
 

Author Comment

by:rmmarsh
ID: 21825410
Is there a way to do it outside of the actual code in the object?  Like in a PHP script?
0
 
LVL 49

Expert Comment

by:Roonaan
ID: 21825461
Where does the html snippet come from then?

You could have:

<?php
if($client->browser_is('IE6')) {
  echo '<script type="text/javascript">document.getElementById("ldheGrLabel2").style.visibility="visible";</script>';
}
?>
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:rmmarsh
ID: 21825547
Snippet is generated HTML code from D.H.E. (Dynamic HTML Editor)...

Put in the code above and got the following error:

Fatal error: Call to a member function browser_is() on a non-object in /home/spokane1/public_html/sandbox-2.php on line 50
<?php 
 

// Browser detection script using PHP Sniff 

// http://phpsniff.sourceforge.net 
 

// Set this to the URL for your site 

$url='http://www.spokanetribalcollege.org/'; // Trailing slash important! 
 

// Include phpsniff code 

require_once ('phpSniff.core.php'); 

require_once ('phpSniff.class.php'); 
 

// Instantiate phpSniff 

$phpSniff=new phpSniff(); 
 

// Get the browser type and version 

$browserCode=$phpSniff->property('browser'); 

$browserVer=$phpSniff->property('maj_ver').$phpSniff->property('min_ver'); 
 

// Lookout for Mozilla 1.0+ and Netscape 6.0+ 

if($client->browser_is('ie6')) {

  echo '<script type="text/javascript">document.getElementById("ldheGrLabel2").style.visibility="visible";</script>';

}

//else 

//{ 

//   // Send all other browsers to the normal index page 

//   header ( 'Location: '.$url.'index.html' );     

//} 

?>

Open in new window

0
 

Author Comment

by:rmmarsh
ID: 21825572
btw, got the same error when it was embedded in the object...
<?php 
 

// Browser detection script using PHP Sniff 

// http://phpsniff.sourceforge.net 
 

// Set this to the URL for your site 

$url='http://www.spokanetribalcollege.org/'; // Trailing slash important! 
 

// Include phpsniff code 

require_once ('phpSniff.core.php'); 

require_once ('phpSniff.class.php'); 
 

// Instantiate phpSniff 

$phpSniff=new phpSniff(); 
 

// Get the browser type and version 

$browserCode=$phpSniff->property('browser'); 

$browserVer=$phpSniff->property('maj_ver').$phpSniff->property('min_ver'); 
 

// Lookout for Mozilla 1.0+ and Netscape 6.0+ 

if($client->browser_is('ie6')) {

  echo '<script type="text/javascript">document.getElementById("ldheGrLabel2").style.visibility="visible";</script>';

}

//else 

//{ 

//   // Send all other browsers to the normal index page 

//   header ( 'Location: '.$url.'index.html' );     

//} 

?>

Open in new window

0
 
LVL 49

Accepted Solution

by:
Roonaan earned 500 total points
ID: 21825580
Change
if($client->browser_is('ie6')) {
Into
if($phpSniff->browser_is('ie6')) {
0
 

Author Comment

by:rmmarsh
ID: 21825921
Thank you so much... that did it...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
object oriented programming comparison 5 57
unset shopping cart session 15 33
Testing a string condition in PHP 6 10
PHP populating an array. 4 5
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

863 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

26 Experts available now in Live!

Get 1:1 Help Now