Closed Bug 300322 Opened 19 years ago Closed 19 years ago

javascript.write function creating "pages" does not work with history navigation

Categories

(Toolkit Graveyard :: Error Console, defect)

x86
Windows XP
defect
Not set
minor

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: gatoatigrado, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b3) Gecko/20050710 Firefox/1.0+
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b3) Gecko/20050710 Firefox/1.0+

I used a javascript.write function that created some links in a page and when
browsing back to the page the links were gone. I am using the newest version so
you should be able to see the error yourself.


Security Error: Content at
wyciwyg://0/file:///C:/Documents%20and%20Settings/tung/Desktop/china%20pictures/nicholas'%20pictures/website/china.html
may not load or link to
file:///C:/Documents%20and%20Settings/tung/Desktop/china%20pictures/nicholas'%20pictures/website/china.html.

Reproducible: Always

Steps to Reproduce:
click an image
click "large" or "web"
click back
Actual Results:  
got a security error, links removed but text still there

Expected Results:  
same page that came up the first time.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>china_pictures</title>
    <script language="javascript">
    document.onclick = iclick;
    function iclick(e)
    {
        if(navigator.userAgent.indexOf("Firefox") != -1)
        {
            if(e.target.tagName == "IMG")
            {
                document.write("<a href=\"images/" +
                e.target.src.substring(e.target.src.indexOf("/images/nail/") +
13, e.target.src.length) +
                "\" >large</a>\n<br/>\n<a href=\"images/web/" +
                e.target.src.substring(e.target.src.indexOf("/images/nail/") +
13, e.target.src.length) +
                "\" >web</a>");
            }
            return;
        }
        if(event.srcElement.tagName == "IMG")
        {
            document.write("<a href=\"images/" +
           
event.srcElement.src.substring(event.srcElement.src.indexOf("/images/nail/") +
13, event.srcElement.src.length) +
            "\" >large</a>\n<br/>\n<a href=\"images/web/" +
           
event.srcElement.src.substring(event.srcElement.src.indexOf("/images/nail/") +
13, event.srcElement.src.length) +
            "\" >web</a>");
        }
    }
    </script>
    <style>
    img, td
    {
        border:none;
        text-align:center;
        font-family:'Trebuchet MS';
        font-size:13px;
    }
    img
    {
        cursor:hand;
    }
    </style>
</head>
<body>
    <span style="font-size: 18pt; font-family: Trebuchet MS">
    Pictures from China<br />

    </span>
    <br />
    <table border="0" cellpadding="10" cellspacing="0">
        <tr>
            <td>
                <img src="images/nail/buddha%20temple.jpg" /><br />
                Light at pagoda</td>
            <td>

                <img src="images/nail/buddha%20temple1.jpg" /><br />
                Stairs down from pagoda</td>
            <td>
                <img src="images/nail/buddha%20wall%20of%20figures.jpg" /><br />
                Wall of Buddha figures</td>
        </tr>
        <tr>
            <td>

                <img src="images/nail/candle.jpg" /><br />
                Candle in temple</td>
            <td>
                <img src="images/nail/construction.jpg" /><br />
                Construction site</td>
            <td>
                <img src="images/nail/decorations%20at%20museum.jpg" /><br />
                Museum decoration</td>

        </tr>
        <tr>
            <td>
                <img src="images/nail/dish0%20at%20museum.jpg" /><br />
                Dish with indentation for thicker glaze</td>
            <td>
                <img src="images/nail/dish1%20at%20museum.jpg" /><br />
                Dish actually illuminated from below</td>

            <td>
                <img src="images/nail/door%20in%20ming%20tomb.jpg" /><br />
                Door at Ming tombs</td>
        </tr>
        <tr>
            <td>
                <img src="images/nail/glass%20at%20lingering%20garden.jpg" /><br />
                Glass at lingering garden</td>

            <td>
                <img src="images/nail/grandpa%20at%20campus.jpg" /><br />
                Grandpa at campus</td>
            <td>
                <img src="images/nail/house%20of%20bookkeeper.jpg" /><br />
                At the house of the bookkeeper</td>
        </tr>
        <tr>

            <td>
                <img src="images/nail/island.jpg" /><br />
                Island</td>
            <td>
                <img src="images/nail/island1.jpg" /><br />
                Island</td>
            <td>
                <img src="images/nail/lake%20at%20campus.jpg" /><br />

                Lake at campus</td>
        </tr>
        <tr>
            <td>
                <img src="images/nail/lake0.jpg" /><br />
                Lake</td>
            <td>
                <img src="images/nail/lake1.jpg" /><br />

                Lake</td>
            <td>
    <img id="IMG1" src="images/nail/leaving%20island.jpg" /><br />
                Leaving the island</td>
        </tr>
        <tr>
            <td>
                <img src="images/nail/Lillian's%20mother's%20funeral%20(4).JPG"
/><br />

                Lillian's mother's grave</td>
            <td>
                <img src="images/nail/pot%20at%20lingering%20garden.jpg" /><br />
                pot at Lingering garden</td>
            <td>
                <img src="images/nail/restaurant.jpg" /><br />
                rocks near restaurant</td>

        </tr>
        <tr>
            <td>
                <img src="images/nail/restaurant1.jpg" /><br />
                rocks near restaurant</td>
            <td>
                <img src="images/nail/restaurant3.jpg" /><br />
                rocks near restaurant</td>

            <td>
                <img src="images/nail/rock%20at%20campus.jpg" /><br />
                rock at campus</td>
        </tr>
        <tr>
            <td>
                <img
src="images/nail/stairs%20to%20outside%20of%20wall%20facing%20china%20(2)%20color%20enhanced.jpg"
/><br />
                stairs at Great Wall</td>

            <td>
                <img src="images/nail/stone%20specular.jpg" /><br />
                pagoda entrance</td>
            <td>
                <img src="images/nail/terra%20cotta.jpg" /><br />
                Terra cotta warriors</td>
        </tr>
        <tr>

            <td>
                <img src="images/nail/terra%20cotta1.jpg" /><br />
                Terra cotta warriors</td>
            <td>
                <img src="images/nail/text%20at%20museum.jpg" /><br />
                museum ceramics introduction</td>
            <td>
                <img src="images/nail/tomb.jpg" /><br />

                tomb</td>
        </tr>
        <tr>
            <td>
                <img src="images/nail/tunnel.jpg" /><br />
                Tunnel</td>
            <td>
                <img src="images/nail/water%20at%20campus.jpg" /><br />

                Water at campus</td>
            <td>
                <img src="images/nail/water%20at%20campus1.jpg" /><br />
                Water at campus</td>
        </tr>
    </table>
</body>
</html>
> Security Error: Content at wyciwyg://7/file:///foo/foo.html may not load or
link to file:///foo/foo.html.

This message("Information", Not "Error" nor "Warning") can be re-produced by
following minimized test case.
 (1) Load a page => <P>'s are displayed 
 (2) Click a <P> => a <A> is displayed.
     But loading doesn't complete due to no document.close.
 (3) Click the <A> => Image is displayed
 (4) Back => above messages is displayed,
             <A> only page is displayed again normaly.
 (5) Switching among 3 pages by Back/Forward has no problem here after. 
      - Original page <==> <A> only page <==> Image page
No problem at step (3) if "document.close();" is written properly.
(Tested with SeaMonkey 2005070906-trunk/Win-2K)

 <head>
 <script type="text/javascript">
 document.onclick = iclick;
 function iclick(e) {
  if(e.target.tagName != "P") { return; }
  var html = '<a href="image.jpg">This is a link</a>' ;
  document.clear() ; document.open() ; // These can be omitted
  document.write(html);
  // document.close() ; // This is required
  return;
 }
 </script>
 </head>
 <body><p>P 001</p><p>P 002</p><p>P 003</p></body>

> I used a javascript.write function that created some links in a page

To bug reporter :
Your coding is not for "adding some links in a page", instead incomplete coding
of above test case(lack of document.close step).
If you want to replace your page by generated links, write at least
"document.close()" properly, and write other tags required for valid/well formed
XHTML document.
If you want to add generated links to you page, use standard way for adding HTML
element, combination of document.createElement & OBJECT.appendChild.
WADA: so is this invalid?
(In reply to comment #2)
> WADA: so is this invalid?
Sorry but I don't know whether it's user's error or Mozilla's problem is
involved, although I think INVALID.
I was testing this out and even the most basic document.write from an html file
fails now in the deerpark alpha2. In Firefox 1.0 this generates a new window
with the words "hello world".
        
win = window.open("","test");      
win.document.write("hello world");     
win.document.close();

Possibly the bug should be elevated to normal or major since this would break
many web applications that use javascript to write to the document of a frame. 

-mark
(In reply to comment #4)
> even the most basic document.write from an html file fails now in the deerpark
alpha2. In Firefox 1.0 this generates a new window with the words "hello world".
>         
> win = window.open("","test");      
> win.document.write("hello world");     
> win.document.close();

Mark, your problem is different problem from this bug.
It sounds regression or new problem caused by some enhancements under
development such as Bug 296639 or Bug 274784.
Test with newest firefox/nightly/latest-trunk build under newly created profile,
and if problem still remains, test with some older builds to identify regression
window, and search Bugzilla, then open new bug when completely new problem.
No response from bug opener for more than one month...
Closing as INVALID.
Reporter, re-open this bug, if and only if problem still occurs even when no
user error is invloved in your problem, please.
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
Product: Firefox → Toolkit
Product: Toolkit → Toolkit Graveyard
You need to log in before you can comment on or make changes to this bug.