Problem with javascript images to view them.

RESOLVED INVALID

Status

()

--
major
RESOLVED INVALID
15 years ago
8 years ago

People

(Reporter: nedik-, Unassigned)

Tracking

({testcase})

Trunk
testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

15 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040616
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040616

Just try this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<body>
<form name="a">
Just choose some picture <input type="file" name="soubor" onchange="aa();">
</form>
<img name="obrazek" src="">
<form name="aaa">
<input type="text" name="b">
</form>
<script>
function aa()
{
var odkaz=document.getElementsByTagName("img");
odkaz["obrazek"].setAttribute("src",document.a.soubor.value);
}
</script>
</body>
</html>


... and you will see, that it run under IE and Opera, but in Mozilla don´t.
Mozilla has problem with showing the pictures, that you choose in the form. 
My question is WHY?

Reproducible: Always
Steps to Reproduce:
1.
2.
3.



Expected Results:  
show the picture on the same page, that you choose in the form.

Comment 1

15 years ago
Created attachment 151742 [details]
testcase

Nedik:
> My question is WHY?

Because the image address is not given in the correct format.
You set the image src attribute to the file name (e.g. "C:\image.gif" on
Windows). However, this is no correct URL. If you enter this string into the
URL-bar you'll see Mozilla at least recognizes it and then forms the correct
URL: "file:///C:/image.gif". But this does of course not happen for attributes
in html files.

You could add "file:///" in the script (not sure if it'll work on Linux), maybe
there's even a JavaScript function to URLify strings...
But as far as I can see, this is not a Mozilla bug and therefore invalid. Do
you consent with this? If not, why not?

The attached testcase can be used for playing with valid and invalid URLS a
bit, I added a button which updates the img src sttribute with whatever is in
the upper textfield (also works for "real" www URLs).
cofirmed
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows XP → All
Hardware: PC → All

Updated

15 years ago
Keywords: testcase

Comment 3

14 years ago
> My question is WHY?

I was doing the exact same thing in my forms and getting the same problem.
Indeed it does appear that prepending the string "file:///" in front of the
"C:\photos\image.jpg" part does indeed solve this particular problem. Good news
is that this also works reliably inside of IE as well!

I was searching for this particular bug report before considering submitting it
myself but am happy to see that someone has an answer to it and now I can get
back to my coding.

Thanks!
testcase still doesn't work work with:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1b1) Gecko/20060812 BonEcho/2.0b1 ID:2006081205

Updated

10 years ago
Component: DOM: Views and Formatting → DOM: CSS Object Model
QA Contact: ian → general
QA Contact: general → style-system
Assignee: general → nobody
Status: NEW → RESOLVED
Last Resolved: 8 years ago
Component: DOM: CSS Object Model → Networking
QA Contact: style-system → networking
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.