- function flash_insert()
-
{
-
var flash_to_insert = '<object type="application/x-shockwave-flash" data="myflash.swf" width="980" height="130">';
-
flash_to_insert = flash_to_insert + '<param name="movie" value="myflash.swf" />';
-
flash_to_insert = flash_to_insert + '</object>';
-
-
document.getElementById('flash_2').innerHTML = flash_to_insert;
-
}
-
-
.
-
.
-
.
-
-
<span id="flash_2"></span>
Hey y'all,
The code above works fine in IE7, Opera9, but NOT in Firefox. Why??
Thanks in advance.
8 1249
Any errors?
If you include the HTML directly without JavaScript, does it work?
Any errors?
If you include the HTML directly without JavaScript, does it work?
No errors in the (FF) console. The HTML content in the variable works when directly included in the HTML document.
The code works as expected in IE7 and Opera9, and what is interesting is that I suspect that the javascript is also working in FF, as there are no errors.
For example; - function flash_insert()
-
{
-
var flash_to_insert = '<br /><a href="javascript:flash_insert();">hello</a>';
-
-
document.getElementById('flash').innerHTML = flash_to_insert;
-
}
or; - function flash_insert()
-
{
-
var flash_to_insert = '<p>hello</p>';
-
-
document.getElementById('flash').innerHTML = flash_to_insert;
-
}
will work in all browsers, but this; - function flash_insert()
-
{
-
var flash_to_insert = '<object type="image/gif" data="../images/frvcc.gif" style="width:98px; height:98px;">';
-
flash_to_insert = flash_to_insert + '</object>';
-
-
document.getElementById('flash').innerHTML = flash_to_insert;
-
}
won't work in FF. It seems as though FF won't show content associated with the <object> tag when inserted by JS.
This may not be a javascript problem after all, but more likely a FF issue.
Sorry if I'm in the wrong forum.
Instead of using innerHTML, have you tried document.createElement("object") and setting attributes/children and appendChild()?
Instead of using innerHTML, have you tried document.createElement("object") and setting attributes/children and appendChild()?
AHA!! Yes, that works. I forgot that my web docs are being served by PHP, which by the way, as you know, can serve different header info to different browsers. I'm serving XHTML1.1 to FF, Opera and any other browser that can handle 'Content-Type: application/xhtml+xml'. IE cannot handle this type of doc, as I understand, so it is being served 'Content-Type: text/html.'
Now the javascript is not working for IE. Is it because IE cannot treat the doc as XML?
What can I do?
Thanks for your help, acoder.
Maybe the code is the problem. - function flash_insert()
-
{
-
var flash_to_insert = document.createElement('object');
-
-
flash_to_insert.setAttribute('type','image/gif');
-
-
flash_to_insert.setAttribute('data','../images/frvcc.gif');
-
-
flash_to_insert.setAttribute('style','width:98px;height:98px;');
-
-
document.getElementById('flash').appendChild(flash_to_insert);
-
}
IE unfortunately uses its non-standard createElement - see link. If you specify the whole HTML string, it'll work. Ugly!
A sincere thanks to you, acoder, for pointing me in the right direction.
I've read the article from the link and it does seem a little ugly.
Since I usually serve up web pages with PHP, I decided to look for a solution using PHP.
What I did was to create code in PHP that selects a set of javascript code to be used when serving HTML, and a different set of javascript code when serving XHTML. Very little extra PHP was needed to link to the proper javascript file, but it did involve writing twice the amount of javascript to accomodate both scenarios.
UGLIER??
It works though, and it seperates the crossbrowser issues I've been having nicely, without much extra machine-cycle or (JS) file download time.
I can now;
1. Serve a web doc (HTML or XHTML, depending on the client) with flash content, without the 'Click to activate and use this control' pop-up, seen in Opera9.
2. Replace flash content dynamically on a web doc whether served-up as HTML or XHTML.
Being a rookie, I feel that I may have reinvented the wheel for no-good reason and there may be an easier solution out there.
Please comment on my rant.
Thanks again, acoder.
In my haste, I forgot about SWFObject (formerly FlashObject). That should handle all the cross-browser issues for you.
PS. just noticed what your user handle spells. Nice! :D
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Perion |
last post by:
I have a simple form with, among other things, an ADODC data control (called
"Adodc1"). The ADO connection to the database tests fine but when I try to add
code to any of the Adodc1 control's event...
|
by: Tony LaPaso |
last post by:
Hi All,
I have a simple style sheet example below and I'm seeing different
results in IE 6 vs. Firefox 1.0.3. I'm not sure which browser is
rendering it correctly but I'm tending to think it's...
|
by: Pat |
last post by:
its seems asp.net validation doesn't fire when using FireFox?
Tested a page and it doesn't fire.
It seems the javascript doesn't fire
Any ideas?
|
by: Aaron Gray |
last post by:
Hi,
I have some code I just cannot seem to get to work properly on FireFox. It
is probably something simple.
On FireFox the following code does not seem to terminate in the browser, but
it...
|
by: Paul Gorodyansky |
last post by:
Hi,
Ran into the problem today - in INPUT field Firefox executes
clean-yp of the content if a user presses Esc, _before_ control goes to
the code via onkeydown - and search showed that it's a...
|
by: WebMatrix |
last post by:
I've been developing ASP.NET 1.1 application, testing it in IE 6.0 on my
development machine. Of course, everything looks normal in IE as it should.
Well, since it's going to be released to...
|
by: richardscheff |
last post by:
Video selector works for IE but not other browsers.
for not IE
<object ID='Player' data="video/dodgeball.wmv" type="video/x-ms-wmv"
width="320" height="280">
<param name="filename"...
|
by: 80s.arcade |
last post by:
Hi.
Please take a look at this page:
http://tinyurl.com/s2l8w
In IE6, putting the mouse on each of the two items highlights the word
in a blue (different image) and shows a tool tip. In...
|
by: johnd126 |
last post by:
I have a cgi program which outputs a fairly hefty amount of
html/javascript for doing a complex slide show sorta thing in a variety
of areas in the browser. I accomplish this by creating a series...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |