Closed Bug 383022 Opened 19 years ago Closed 18 years ago

document.write for embed won't work.

Categories

(Firefox :: General, defect)

2.0 Branch
x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED WONTFIX

People

(Reporter: henry.fai.hang.chan, Unassigned)

Details

(Whiteboard: WFM)

Attachments

(1 file, 2 obsolete files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4 in my page, i put in a document.write for <object>, and it wouldn't display anything when i clicked on the trigger. I checked the error console, nothing happened. I put in a document.write for <embed> instead, and the object flashed. it started playing for one sec then disappears. In IE, it shows, plays, but when i move out of the player, it stops. Reproducible: Always Steps to Reproduce: 1. go to a site with embed in a document.write 2.it will flicker once 3. Actual Results: the box flickers Expected Results: start playing, still play when i move my mouse to somewhere else
Can you provide a testcase? Note that the correct way to invoke plug-ins in IE and Mozilla differ, see http://developer.mozilla.org/en/docs/Using_the_Right_Markup_to_Invoke_Plugins for more details.
Henry, you may want to also look at Using Web Standards in your Web Pages Section 2.2.4.1 What if I use <embed> for flash or for a video? http://developer.mozilla.org/en/docs/Using_Web_Standards_in_your_Web_Pages#What_if_I_use_.3Cembed.3E_for_flash_or_for_a_video.3F and also at Video or audio does not play http://kb.mozillazine.org/Video_or_audio_doesn't_play
doesn't work with objects either: var a ='<object type="video/x-ms-wmv" data="HKSAR10.wmv" width="330" height="270"><param name="movie" value="HKSAR10.wmv"><param name="autostart" value="true"><param name="controller" value="true"></object>' document.write(a); (that var script is all one line)
Henry, 1- We have to see the whole code; best is to upload a reduced testcase (like Gavin asked you) and give an URL so that we can examine the webpage. 2- We don't know if (and how) you open the document stream for that write and if you close it. E.g.: (...) document.open(); document.write(a); document.close(); Anyway, why do you need to embed dynamically such code... why not just declare your <object ...> in the document? What I mean here is why write that HTML code dynamically? 3- We don't know if you have the WMP plugin for Firefox installed. Go to http://support.mozilla.com/kb/Windows+Media+Player and then to http://port25.technet.com/pages/windows-media-player-firefox-plugin-download.aspx but make sure you download and install wmpfirefoxplugin.exe (318 904 bytes) and that you have+use WMP 11 http://www.microsoft.com/windows/windowsmedia/download/AllDownloads.aspx 4- Your code, as written, does not escape backslashes... you need to fix this: var a ='<object type="video\/x-ms-wmv" data="HKSAR10.wmv" width="330" height="270"><param name="movie" value="HKSAR10.wmv"><param name="autostart" value="true"><param name="controller" value="true"><\/object>' Common HTML Validation Problems Writing HTML in a SCRIPT Element http://www.htmlhelp.com/tools/validator/problems.html.en#script (English) http://www.htmlhelp.com/tools/validator/problems.html#script 5- Instead of <param name="movie" value="HKSAR10.wmv"> please try <param name="src" value="HKSAR10.wmv"> if the above 4 items did not work. 6- My reduced testcase: http://www.gtalbot.org/BugzillaSection/Bug374183PlayingVideoWithWindowsMediaPlayer11.html loads and plays (MIME type is video/x-ms-wmv). Regards, Gérard
it in a function command that writes the video when I click a button.
Attached file testcase (obsolete) —
Workaround: document.body.innerHTML = a; document.body.innerHTML = a; You need to declare twice or bug 419251 happens. THIS IS NOT A DUPLICATE OF BUG 419251 BUT THE WORKAROUND CAUSES ANOTHER BUG WHICH IS FIXED BY DUPLICATING THE COMMAND.
Version: unspecified → 2.0 Branch
Henry, Thank you for providing a testcase. 1- You gave a link reference to your movie, as src and data="HKSAR10.wmv" as loaded on bugzilla server. You would need to give the full link address of your movie so that the testcase would link to it and so that we could try your testcase 2- language="javascript" Language is a deprecated attribute: don't use it. Just use the type attribute. In some cases, it can make the browser choose a primitive, previous version of the language, not the latest. What you did may not be an error but it is not recommendable and generally discouraged. http://www.javascripttoolbox.com/bestpractices/#script 3- In your testcase, you implicitly open the document for writing but you do not close it. Please use document.open() and close() like I said in comment #4. " The close method closes a stream opened with the document.open method. If the stream was opened to layout, the close method forces the content of the stream to display. (...) The document.close method forces the content of the stream to display in the window. (...)" http://devedge-temp.mozilla.org/library/manuals/2000/javascript/1.3/reference/document.html#1197324 Also DOM 2 HTML: http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-98948567 "Closes a document stream opened by open() and forces rendering." http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-72161170 http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-75233634 Gecko DOM Reference http://developer.mozilla.org/en/docs/DOM:document.close Generally rule: if you use document.write(), then first use document.open() and then, after, use document.close(). 4- Using a command button is going to be more semantic and more correct than a link. A link must always point to a real URL, not to javascript code. You say yourself that it is a function command to write... so it can not be a link. Just replace with <button type="button" onclick="writevideo();">See the HKSAR10 video</button>
I've tested it using the w3c validator. In XHTML I can't have it but in HTML 4 I need it for it to validate. I'll try using d.open and d.close.
Attached file testcase two. (obsolete) —
Attachment #305481 - Attachment is obsolete: true
Attached file testcase three —
Attachment #306434 - Attachment is obsolete: true
> In XHTML I can't have it "How is the treatment of application/xhtml+xml documents different from the treatment of text/html documents? (...) document.write() is not supported. The stream that is going into the parser can't be tampered with in mid-parse." Mozilla Web Author FAQ http://www.mozilla.org/docs/web-developer/faq.html#xhtmldiff Regarding your testcase 3 (attachment 306435 [details]), 1- I informed you that language is a deprecated attribute. So, <script type="text/javascript" language="javascript"> must be replaced with <script type="text/javascript"> 2- I see no reason whatsoever to use a transitional DTD in all of your testcases. 3- the default type for HTML button is submit, not button. So you have to declare it as such. So, <button onClick="writevideo();">Click here to see the video.</button> must be replaced with <button type="button" onclick="writevideo();">Click here to see the video.</button> 4- When HTML code is going to be converted into a string, then all "/" must be escaped. So, data="www.gov.hk/en/theme/10/videos/HKSAR10.wmv" must be replaced with data="www.gov.hk\/en\/theme\/10\/videos\/HKSAR10.wmv" Why not use the http:\/\/ in that string? Another question I still have: why do you need to embed dynamically such code... why not just declare your <object ...> in the document? You could still set the WMP console to <param name="autostart" value="false"> (not to autostart) Anyway... So far, nothing in this bug report indicates a bug actually occuring in Firefox. If you need coding assistance for your webpage, then try "Web Development/Standards Evangelism" mozillazine forum: http://forums.mozillazine.org/ and http://forums.mozillazine.org/viewforum.php?f=25 or http://forums.mozine.cn/ (in Chinese) and I know there is a forum dedicated to webpage development, web standards http://forums.mozine.cn/ I recommend you have a look at Using Web Standards in your Web Pages Section 2.2.4.1 What if I use <embed> for flash or for a video? http://developer.mozilla.org/en/docs/Using_Web_Standards_in_your_Web_Pages#What_if_I_use_.3Cembed.3E_for_flash_or_for_a_video.3F if all the above still do not work. Regards, Gérard
Whiteboard: WFM
>> In XHTML I can't have it ><script type="text/javascript" language="javascript"> >must be replaced with ><script type="text/javascript"> The "IT" there meant the language attribute. I meant in XHTML I can't have the language attribute, but in HTML transitional 4.01 I NEED it (well not in Strict, but I just have a habit of using transitional.) My server sends the pages as text/HTML. ----------------- I don't want a object to be shown at webpage load. I wanted it to play once the object is seen. ------------------ I know other workarounds, such as a href to point to a new page to show it (that would require much less code), but then I am focusing on just this method. I'm testing on Firefox 2.0 with the first and last testcases and then we'll know what the heck is really the problem.
I know the problem of the page now. Firefox 2.0 just doesn't seem to "flush" some commands to the page without document.close(); or declaring twice. Not escaping / works if it was escaped in both firefox 2 and 3 just for this document. The language attribute is not a problem when I have HTML 4 trans and it works the same in firefox 2 and 3 with / without it. (well maybe just LOOKS)
I'm moving this to HENDRIX
I still don't know why embed elements will show for a second and revert but objects do nothing without document.close()!
JavaScript Libraries really needs some BIG cleanup
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: