IE ActiveX Change
"Click to activate and use this control"

Thursday, April 20, 2006

Simple Write Out (With optional RegEx)

An alternative to all the official solutions is instead of passing through a list of parameters and attributes for the width, height, bgcolor etc which the receiving JavaScript function then needs to join together again, is to simply pass the entire <object> to a JavaScript function that writes it back out to the screen.

The JavaScript function for this is very simple:
function ieoutput(theText){

The tricky part comes with replacing the <object> tag with a call to the JavaScript function, and including it in a <noscript> tag too, to allow for browsers with javaScript disabled.

So that the final code looks like:

<script type="text/javascript">echocontent('<object ...' +
'your code' +
'your code' +
<object ...
your code

As a short cut, we can use the Regular Expression Search and Replace feature of TextPad.

For the normal 7 lines of HTML code for Flash we can search for:

And replace with:
<script type="text/javascript">ieoutput('\1'
\+\n '\2' \+\n '\3' \+\n '\4' \+\n '\5' \+\n '\6' \+\n

If you have a different number of lines in your <object> the Regular Expression can be changed accordingly.


Post a comment

<< Home