• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 227
  • Last Modified:

Need to change an objects property..

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
rmmarsh
Asked:
rmmarsh
  • 4
  • 3
1 Solution
 
RoonaanCommented:
<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
 
rmmarshAuthor Commented:
Is there a way to do it outside of the actual code in the object?  Like in a PHP script?
0
 
RoonaanCommented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rmmarshAuthor Commented:
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
 
rmmarshAuthor Commented:
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
 
RoonaanCommented:
Change
if($client->browser_is('ie6')) {
Into
if($phpSniff->browser_is('ie6')) {
0
 
rmmarshAuthor Commented:
Thank you so much... that did it...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now