Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks, I am getting particularly frustrated with netscape especially v. 4.75. I simply want to disply an image submitted by the CGI user. The code works lovely in an Internet Explorer browser but netscape just displays one of those horrible box-like things that are indescribable. Anyway, I was hoping someone would have some helpful suggestions... It's not due to poor html as everything else is displyed by netscape.
print STDOUT "<P><div align=\"center\"><img src=\"$image\"></div>";

Replies are listed 'Best First'.
Re: CGI + netscape problems
by davorg (Chancellor) on Jan 29, 2003 at 17:04 UTC

    You can't have a <div> within a <p> in well-formed HTML as they are both block elements (see here). Netscape is well-known for being picky on non-standard HTML so any time you get a problem like this it's worth testing your HTML in an HTML Validator.

    Why not just put the centre attribute on the <p> tag?

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: CGI + netscape problems
by scain (Curate) on Jan 29, 2003 at 16:54 UTC
    Another suggestion following up on dragonchild's: try displaying the image another way, just for kicks, like just by copying the url for the image and pasting it into the location bar. Does that work? If so, it is a problem with the html and Netscape 4.*, if not, perhaps the image is subtlely flawed/corrupted, and IE's renderer is better at handling it.

    Scott
    Project coordinator of the Generic Model Organism Database Project

Re: CGI + netscape problems
by neilwatson (Priest) on Jan 29, 2003 at 16:42 UTC
    Have you viewed the html source from the browser? Often that will give you a hint.

    Neil Watson
    watson-wilson.ca

      the page source suggests that the image should be there! thanks for the suggestion though.
Re: CGI + netscape problems
by hardburn (Abbot) on Jan 29, 2003 at 16:55 UTC

    Close your <P> tag. Netscape tends to be really picky about tags being closed, even when the W3C says it's optional.

    I don't know if this will actually solve the problem, but you might as well try.

Re: CGI + netscape problems
by Bismark (Scribe) on Jan 29, 2003 at 16:57 UTC
    Without more of the code it is tough to see where the problem might lie. Just looking at your html I see one issue. The image tag and the P tag should be changed so that they are not empty elements. Netscape always has problems with those. Try this;
    print STDOUT "<P><div align=\"center\" \/><img src=\"$image\" \/></div +>";
    I added a space before the trailing > and added the backslash both in the P tag and the img tag. This lets the browser know not to expect anything else. Don't know if that will help 100% with your question, but it could be part of the issue.
    Updated to fix a grammatical error
    Kerry
    "Yet what are all such gaieties to me Whose thoughts are full of indices and surds?" quotes the Lama
Re: CGI + netscape problems
by dragonchild (Archbishop) on Jan 29, 2003 at 16:43 UTC
    I'm not attempting to be facetious, but tell your users that you do not support any version of Netscape below 6.2. This sounds like a number of issues we've run into where I work. We do a web app that uses a ton of stuff, including <div> and the like. If you can't make it work, don't support it. You didn't write the browser, you can't make the browser better. The people who developed it did - it's called free upgrades.

    Of course, if you can't (for whatever reason), it sounds like you're going to have to detect that it's Netscape 4.75 and render the image some other way.

    (I'm assuming you know what you're doing re: CGI and image-rendering.)

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Re: CGI + netscape problems
by Sifmole (Chaplain) on Jan 29, 2003 at 17:00 UTC
    What is the value of $image when you are printing? That might be the source of the problem. Also check that all your quotes are closed, because a missing one somewhere can often cause odd results.
Re: CGI + netscape problems
by Gilimanjaro (Hermit) on Jan 29, 2003 at 17:16 UTC
    What does $image contain? I remember once having problems because netscape refuses (justly) to convert backslashes to slashes in an url...

    Try inserting:

    $images=~s/\\/\/g;

    before the print line... That should convert any backslashes to forward slashes.

    "Oy! What's that between my teeth?! Someone get me a toothpick!

    Update: added a missing squigly thing thanks to Bilbo++

      That should probably be

      $image =~ s/\\/\//g;

      (=~ rather than =, and you were missing a /)

Re: CGI + netscape problems
by Cody Pendant (Prior) on Jan 29, 2003 at 20:19 UTC
    I don't like to be mean about this, but why are we even answering this question?

    So many times I see posters get slapped down for asking questions with No Perl Content.

    This question has No Perl Content because the HTML syntax works in one browser, not another, therefore it's an HTML/Browser incompatibility problem.

    I'd like to help too, and my money's on the slashes idea, or more probably, a CSS bug that's not visible to us because we can only see this section of the code -- but the next time someone comes along and asks a NPC question, and an admin boots it, they'd be entitled to say "this guy got nine replies! Why are you being so mean to me?"
    --

    “Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.”
    M-J D
Re: CGI + netscape problems
by artist (Parson) on Jan 29, 2003 at 17:46 UTC
    Try inserting the size of the image. To find out with perl, you can use Image::Size.

    artist