WC2 errors... Any tips?

69 views
Skip to first unread message

Micky Hulse

unread,
Sep 13, 2012, 10:52:42 PM9/13/12
to writecaptu...@googlegroups.com
Hello,

I've finally had a chance to seriously test the new "simple" API with
my latest code and I've stumbled across a few issues.

---

1. IE 8.0.6001.19222

Getting this error:

Invalid argument. element.write.js, line 291 character 6

Which is this line:

curParentNode.appendChild( elem );

JSBin domo here:

<http://jsbin.com/epivoy/1/>

Non js-bin demo here:

<http://assets.registerguard.com/demos/wc/tests/test2.html>

Here's another test, where the above ad appears in a "group" of other
ads (refresh browser to cycle through ads):

<http://assets.registerguard.com/demos/wc/tests/test1.html>

Finally, here's a way more complex demo page:

<http://registerguard.github.com/ads-on-demand/demos/advanced/demo1.html>

... and here's the debug info IE 8 generates:

<http://pastebin.com/B7mHU2j6>

... with the last few lines being:

LOG: WC queue.writefalse10
LOG: WC charsfalseargs
[object Object]10
LOG: WC queue.writefalse10
LOG: WC startfalseargsobject[object Object],[object Object],[object
Object],[object Object]false[object Object]10
LOG: WC startfalseargsparam[object Object],[object Object]true[object Object]10
LOG: WC startfalseargsparam[object Object],[object Object]true[object Object]10
LOG: WC startfalseargsparam[object Object],[object Object]true[object Object]10
LOG: WC startfalseargsparam[object Object],[object Object]true[object Object]10
LOG: WC startfalseargsparam[object Object],[object Object]true[object Object]10
LOG: WC startfalseargsparam[object Object],[object Object]true[object Object]10
LOG: WC startfalseargsembed[object Object],[object Object],[object
Object],[object Object],[object Object],[object Object],[object
Object],[object Object],[object Object],[object Object],[object
Object]true[object Object]10
Invalid argument. element.write.js, line 291 character 6
Invalid argument. element.write.js, line 291 character 6

---

2. IE 7.0.6002.18005

Some broken images load. Some ads not loading. I think it's related to
the same problem above.

---

3. I have not tested IE 6.

---

4. Firefox 3.6.1.8

I think I see something similar to this Firefox bug:

"FireFox sits on "Transferring data from…" or "Read…""
<http://stackoverflow.com/questions/304471/firefox-sits-on-transferring-data-from-or-read>

The ads will load, but I get the problem above. :(

Sorry, I don't have a simple demo to share, but I'd gladly make one if
there was interest.

---

I'm wondering if it's my code, the ads/ad code and/or element.write?

Any tips on where I could look to fix these issues (I'm mostly
concerned about the IE issue)? I'm wondering if I should go back to
using the more advanced API?

Thanks so much for listening!

Cheers,
Micky

noah

unread,
Sep 14, 2012, 8:26:21 AM9/14/12
to writecaptu...@googlegroups.com
On Thu, Sep 13, 2012 at 9:52 PM, Micky Hulse <rgm...@gmail.com> wrote:
> Any tips on where I could look to fix these issues (I'm mostly
> concerned about the IE issue)? I'm wondering if I should go back to
> using the more advanced API?

The simple API should have the same results.

I'll try to look into this over the weekend.

Micky Hulse

unread,
Sep 14, 2012, 2:23:04 PM9/14/12
to writecaptu...@googlegroups.com
Hi Noah!

Thanks so much for getting back to me, I really appreciate it.

On Fri, Sep 14, 2012 at 5:26 AM, noah <iam...@gmail.com> wrote:
> The simple API should have the same results.

That's great news! I would hate to not have the option to use the simple API. :)

In fact, I just re-tested my old tests (using the old API) from a
month (or so) ago, and I'm getting the same results.

> I'll try to look into this over the weekend.

Thanks! In the meantime, I'm going to do some more testing. I just
realized that OpenX changed their code base so that could explain why
the results I'm getting are different from what they were a month ago.

I'm going to spend the day running more tests and I'll get back to you
with my findings... It could be that I just need to re-think how I'm
placing the OpenX tags on my page.

Anyway, I'll let you know if I make any progress... I'd hate to waste
your time on something that has nothing to do with your code.

Thanks again! I'll be back.

Cheers,
Micky

--
Micky Hulse
Web Content Editor
The Register-Guard
3500 Chad Drive
Eugene, OR 97408
Phone: (541) 338-2621
Fax: (541) 683-7631
Web: <http://www.registerguard.com>

Micky Hulse

unread,
Sep 14, 2012, 7:11:13 PM9/14/12
to writecaptu...@googlegroups.com
I'm back!

On Fri, Sep 14, 2012 at 11:23 AM, Micky Hulse <rgm...@gmail.com> wrote:
> Thanks! In the meantime, I'm going to do some more testing. I just
> realized that OpenX changed their code base so that could explain why
> the results I'm getting are different from what they were a month ago.
>
> I'm going to spend the day running more tests and I'll get back to you
> with my findings... It could be that I just need to re-think how I'm
> placing the OpenX tags on my page.
>
> Anyway, I'll let you know if I make any progress... I'd hate to waste
> your time on something that has nothing to do with your code.

Ugh, I've tried everything I can think of to get past the error... No
luck so far.

If you do happen to have time to take a look at the code this weekend
I'd be forever thankful! :)

If I do find a workaround, I'll let you know.

Many thanks again!
Cheers,
Micky

MasJ

unread,
Sep 14, 2012, 8:10:00 PM9/14/12
to writecaptu...@googlegroups.com
Hi Micky

Thanks for posting this followup thread. Just wanted to note that I'm facing the exact same issue with WC2 under IE8. I'm using tribalfusion's ads so maybe it's an issue with how sequential writes are handled using the simple api ?

I'm afraid that I couldn't fix it myself otherwise I'd submit a pull request. Will try to look into it over the weekend.

Micky Hulse

unread,
Sep 18, 2012, 7:39:08 PM9/18/12
to writecaptu...@googlegroups.com
Hello!

On Fri, Sep 14, 2012 at 5:26 AM, noah <iam...@gmail.com> wrote:
> I'll try to look into this over the weekend.

So, I did a little sleuthing, and here's where I'm at...

In IE<8, the code appears to be stopping at this line:

#291 curParentNode.appendChild( elem );

I turned on debug for element.write, and the `elem` var contains this
code (at least, from what I can tell):

[snip]

<embed width="300" height="250" src="http://s0.2mdn.net/1678108/NEW
PDX McD-DollarDrink-300x250.swf"
flashvars="moviePath=http://s0.2mdn.net/1678108/&moviepath=http://s0.2mdn.net/1678108/&clickTAG=http%3A//ad.doubleclick.net/click%253Bh%253Dv8/3cf4/3/0/%252a/h%253B260974778%253B0-0%253B0%253B85104935%253B4307-300/250%253B49753400/49746008/1%253B%253B%257Esscs%253D%253fhttp%3A//www.mcdonalds.com/us/en/home.html&clickTag=http%3A//ad.doubleclick.net/click%253Bh%253Dv8/3cf4/3/0/%252a/h%253B260974778%253B0-0%253B0%253B85104935%253B4307-300/250%253B49753400/49746008/1%253B%253B%257Esscs%253D%253fhttp%3A//www.mcdonalds.com/us/en/home.html"
type="application/x-shockwave-flash" quality="high"
swliveconnect="true" wmode="opaque" name="DCF260974778"
base="http://s0.2mdn.net/1678108" allowscriptaccess="never">

[/snip]

... and the parent tag is:

[snip]

<object id="DCF260974778" width="300" height="250"
classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">

[/snip]

Here's the debug output (gotten via Firefox Firebug):

[snip]

WRITE start append <embed width="300" height="250"
src="http://s0.2mdn.net/1678108/NEW PDX McD-DollarDrink-300x250.swf"
flashvars="moviePath=http://s0.2mdn.net/1678108/&moviepath=http://s0.2mdn.net/1678108/&clickTAG=http%3A//ad.doubleclick.net/click%253Bh%253Dv8/3cf4/3/0/%252a/h%253B260974778%253B0-0%253B0%253B85104935%253B4307-300/250%253B49753400/49746008/1%253B%253B%257Esscs%253D%253fhttp%3A//www.mcdonalds.com/us/en/home.html&clickTag=http%3A//ad.doubleclick.net/click%253Bh%253Dv8/3cf4/3/0/%252a/h%253B260974778%253B0-0%253B0%253B85104935%253B4307-300/250%253B49753400/49746008/1%253B%253B%257Esscs%253D%253fhttp%3A//www.mcdonalds.com/us/en/home.html"
type="application/x-shockwave-flash" quality="high"
swliveconnect="true" wmode="opaque" name="DCF260974778"
base="http://s0.2mdn.net/1678108" allowscriptaccess="never"> to
<object id="DCF260974778" width="300" height="250"
classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">

[/snip]

After googling around for a bit, I discovered that appendChild()
appears to not work for certain HTML elements:

<http://www.codingforums.com/showthread.php?t=11625>
<http://www.donatofurlani.it/category/programming/34/js_DOM_Flash_InternetExplorer>
<http://bugs.jquery.com/ticket/925>

I'm suspecting that element.write is trying to appendChild() the
<embed> code to an <object> tag? Could this be unsupported by IE<7?

I've tried:

[snip]

if (tagName == 'embed') {
curParentNode.innerHTML = elem; // First things first, I probably
need to convert this object to a string.
} else {
curParentNode.appendChild( elem );
}

[/snip]

... with not much luck (for obvious reasons, I was just hoping the fix
would be as simple as the above).

Side note: I'm reading through this article now:

<http://pipwerks.com/2011/05/30/using-the-object-element-to-dynamically-embed-flash-swfs-in-internet-explorer/>

... looks like some interesting/related info.

Anyway, does anyone have any thoughts?

It's strange though... I feel like I've seen flash ads work in IE<8
using WC2! Why would this Flash ad be any different?

noah

unread,
Sep 18, 2012, 8:53:50 PM9/18/12
to writecaptu...@googlegroups.com
I added a test to to the test suite that shows you're on the right
track (or use this fiddle: http://jsfiddle.net/XvLMS/)

I don't have time to work it out myself in the near future, but I'll
take a pull request that fixes that test in IE8.

Micky Hulse

unread,
Sep 18, 2012, 9:59:25 PM9/18/12
to writecaptu...@googlegroups.com
Hi Noah! Thanks so much for the reply, I really appreciate it. :)

On Tue, Sep 18, 2012 at 5:53 PM, noah <iam...@gmail.com> wrote:
> I added a test to to the test suite that shows you're on the right
> track (or use this fiddle: http://jsfiddle.net/XvLMS/)

Cool! I'm glad to hear that I'm on the right track here. Thanks for
taking a look!

Thanks for adding the test, I will take a closer look when I get home
(just now leaving work).

> I don't have time to work it out myself in the near future, but I'll
> take a pull request that fixes that test in IE8.

No worries! I'm going to try to figure this out and if I find a good
solution, I'll send you a pull request. :)

Thanks again for your help and for the awesome code!

Talk soon.

Cheers,
M

Micky Hulse

unread,
Oct 3, 2012, 5:41:19 PM10/3/12
to writecaptu...@googlegroups.com
On Tue, Sep 18, 2012 at 6:59 PM, Micky Hulse <rgm...@gmail.com> wrote:
> No worries! I'm going to try to figure this out and if I find a good
> solution, I'll send you a pull request. :)

I've been kinda banging my head on the keyboard trying to figure out
the best way to handle <object>s that have <embed>s...

Just thought I'd throw out an e-mail asking if anyone has any
suggestions for a fix... Everything I've tried so far isn't working.

As a workaround, we've been playing with the idea of sending IE<8 a
non-flash based ad (our ad serving software, OpenX, let's us browser
sniff like that). It should work for prime time, but I'd love to find
a solution...

I'm going to keep working on the code, but I was just wondering if
anyone had any suggestions/tips on possible fixes/solutions...
Anything would help.

Thanks!

Cheers,
Micky

Micky Hulse

unread,
Oct 3, 2012, 5:51:09 PM10/3/12
to writecaptu...@googlegroups.com
Typo:

On Wed, Oct 3, 2012 at 2:41 PM, Micky Hulse <rgm...@gmail.com> wrote:
> As a workaround, we've been playing with the idea of sending IE<8 a

That should say IE<=8.

noah

unread,
Oct 4, 2012, 10:15:43 PM10/4/12
to writecaptu...@googlegroups.com
Can you use innerHTML to add an element to the object tag?

Micky Hulse

unread,
Oct 5, 2012, 1:17:45 PM10/5/12
to writecaptu...@googlegroups.com
Hi Noah! Thanks for the reply, I really appreciate it. :)

On Thu, Oct 4, 2012 at 7:15 PM, noah <iam...@gmail.com> wrote:
> Can you use innerHTML to add an element to the object tag?

I have played around with innerHTML, but with no luck so far. I think
what I need to do is create a simpler test case... I have been working
on element.write/WC2, in IE8, using IE's debug tool (which sucks when
compared to Firebug).

I think what I'll do is just use your simpler test case and/or create
one of my own to just learn more about IE's limitations for when it
comes to <object>s and appendChild()/innerHTML.

I'll do some more testing and post back my results this weekend.

Like I said before, we're currently serving up the ads in an iFrame
(that's one of the options that OpenX offers) specifically for IE...
It makes our code a bit more complex (having to test for IE and then
change-up the ad calls so they serve the iFrame). It works, but it
would be nice to not have to get jiggy with things. :D

I'll be back!

Cheers,
Micky

Micky Hulse

unread,
Oct 10, 2012, 12:48:31 AM10/10/12
to writecaptu...@googlegroups.com
Hi Noah, all...

Here's my latest test page:

<http://assets.registerguard.com/demos/wc2/test3.html>

... that's sans-WC2 or element.write. View source to see my tests.

---

Problem:

IE8 will not allow innerHTML or appendChild() if the parent is an
<object> and the child is an <embed>.

I did not get a chance to test in IE < 8, but I assume the problem is there too.

---

My current conclusion:

I think it's going to be almost impossible to get IE to appendChild()
or innerHTML an <embed> to an <object>. :(

---

Possible "solution" #1:

I was able to "fake out" IE, and convert the <embed> into a <param>
and, to my surprise, IE allowed appendChild()!

In other words, I took this:

<embed width="300" height="250" allowscriptaccess="never"
base="http://s0.2mdn.net/1678108" name="DCF260974778" wmode="opaque"
swliveconnect="true" quality="high"
type="application/x-shockwave-flash"
flashvars="moviePath=http://s0.2mdn.net/1678108/&amp;moviepath=http://s0.2mdn.net/1678108/&amp;clickTAG=http%3A//ad.doubleclick.net/click%253Bh%253Dv8/3d08/3/0/%252a/h%253B260974778%253B0-0%253B0%253B85104935%253B4307-300/250%253B49753400/49746008/1%253B%253B%257Esscs%253D%253fhttp%3A//www.mcdonalds.com/us/en/home.html&amp;clickTag=http%3A//ad.doubleclick.net/click%253Bh%253Dv8/3d08/3/0/%252a/h%253B260974778%253B0-0%253B0%253B85104935%253B4307-300/250%253B49753400/49746008/1%253B%253B%257Esscs%253D%253fhttp%3A//www.mcdonalds.com/us/en/home.html"
src="http://s0.2mdn.net/1678108/NEW%20PDX%20McD-DollarDrink-300x250.swf">

... and converted it to this:

<param width="300" height="250" allowscriptaccess="never"
base="http://s0.2mdn.net/1678108" name="DCF260974778" wmode="opaque"
swliveconnect="true" quality="high"
type="application/x-shockwave-flash"
flashvars="moviePath=http://s0.2mdn.net/1678108/&amp;moviepath=http://s0.2mdn.net/1678108/&amp;clickTAG=http%3A//ad.doubleclick.net/click%253Bh%253Dv8/3d08/3/0/%252a/h%253B260974778%253B0-0%253B0%253B85104935%253B4307-300/250%253B49753400/49746008/1%253B%253B%257Esscs%253D%253fhttp%3A//www.mcdonalds.com/us/en/home.html&amp;clickTag=http%3A//ad.doubleclick.net/click%253Bh%253Dv8/3d08/3/0/%252a/h%253B260974778%253B0-0%253B0%253B85104935%253B4307-300/250%253B49753400/49746008/1%253B%253B%257Esscs%253D%253fhttp%3A//www.mcdonalds.com/us/en/home.html"
src="http://s0.2mdn.net/1678108/NEW%20PDX%20McD-DollarDrink-300x250.swf">

... and I was able to appendChild() the "faux" param to <object>!

That's when I hit a brick wall... How can I convert the "faux" <param>
BACK into an <embed> after having already appendChild() to the
<object>? I thought maybe regex? Unfortunately, I haven't had the
spare time to go further with this idea (not to mention, it seems very
patch hacky).

Question: What do you think of the above "solution"? Would this be a
patch that you'd incorporate into the main branch of either
element.write or WC2 (if I was able to create a fully working patch)?
In other words, if the above sounds like a bad idea, and you'd never
include that type of hackiness in the official release of
element.write or WC2, then I'd happily to move on to testing other
solutions. :)

---

Possible "solution" #2:

Just SKIP <object> or <embed>!!!! :D

In this demo:

<http://assets.registerguard.com/demos/wc2/test1.html>

I modified WC2 to ignore <embed>.

Unfortunately, that stops the ad from working in FF/Mac and IE8/PC.

Note: IE8 will not throw an error (because <embed> is skipped) but
then the ad does not show, and the page won't stop "loading" (i.e. the
spinner in the tab just keeps going and going and going and...).

So, this patch ain't the solution, BUT....

---

Possible "solution" #3 (based on "solution" #2 above):

Keep in mind, I'm still trying to wrap my head around WC2 and element.write...

At this point, based on my knowledge of your scripts to date, I'm
thinking that the best solution would be to __skip__ the element.write
parsing of an <object> if it contains an <embed>.

My question: Would this solution work? I don't yet fully understand
how all of your code works, so it's hard for me to make a judgement
call...

Pseudo patch code:

WC2 parse HTML
* Current tag is an <object>
* Code checks for immediate child <embed>
* If <embed> exists:
* Skip <object> and appendChild() back to page (?)
* Continue parsing HTML.

I just can't think of a better solution (other than maybe "solution" #1 above).

Question:

When would element.write be needed if it's an <object>? Would it be
out of ordinary (or the mission/goals of your code) to have WC2 or
element.write skip parsing of an <object>, and just spit the <object>
back out to its parent element without parsing any of its children?

I kinda like this solution, but I'm not sure of the best spot to put
it in WC2 or element.write.

---

Lol, did any of that make sense?

Did I mention that I hate IE? :D

Thoughts?

I think I need a kick in the right direction here... Do you think I
should be patching WC2 or element.write? Both? None? Seems like
skipping tags works great in WC2, but appendingChildren would be best
done in element.write... Am I talking crazy here?

Thanks for listening.

Micky

noah

unread,
Oct 10, 2012, 9:22:04 AM10/10/12
to writecaptu...@googlegroups.com
Well, WC2 is structured the way it is because it's often important
that elements be immediately available. But in the case of an object
tag, I don't think that's necessarily true. Seems like the browser
wont let you access it.

Here's what I would do:
If you encounter an object tag, stop writing tags out normal and
instead start building HTML. e.g., "<object". When you get to the end
object tag, do this: parent.innerHTML += html;

Micky Hulse

unread,
Oct 12, 2012, 1:03:11 AM10/12/12
to writecaptu...@googlegroups.com
Hi Noah! Thanks for getting back to me so quickly, I really appreciate it. :)

On Wed, Oct 10, 2012 at 6:22 AM, noah <iam...@gmail.com> wrote:
> Well, WC2 is structured the way it is because it's often important
> that elements be immediately available.

Thanks for clarification. Like I said, I'm still trying to wrap my
head around your awesome code... The above explanation helps. :)

> But in the case of an object
> tag, I don't think that's necessarily true. Seems like the browser
> wont let you access it.

Good point.

From our tests, it looks like all IE versions have issues with
<object> and child <embed>. We're currently testing a wide range of
different types of ads (using OpenX as the ad server) and so far
that's the only major problem we've seen.

Update: Hmmm, actually, based on some of our most recent tests, it
looks like an <embed> tag (sans <object> parent) is problematic as
well... I need to do some more testing to confirm though.

> Here's what I would do:
> If you encounter an object tag, stop writing tags out normal and
> instead start building HTML. e.g., "<object". When you get to the end
> object tag, do this: parent.innerHTML += html;

Awesome! Thanks for tip!

I'll be back soon with, hopefully, a working patch.

Much appreciated!

Cheers,
Micky

Micky Hulse

unread,
Oct 14, 2012, 4:27:19 PM10/14/12
to writecaptu...@googlegroups.com
On Thu, Oct 11, 2012 at 10:03 PM, Micky Hulse <rgm...@gmail.com> wrote:
> Update: Hmmm, actually, based on some of our most recent tests, it
> looks like an <embed> tag (sans <object> parent) is problematic as
> well... I need to do some more testing to confirm though.

In the above paragraph, I was wrong... I've been looking at Firebug in
Firefox and the output of this particular ad script is an <embed>.

I did not think to check IE to see if the generated source code
matched what I was seeing in FF.

Long story short, the ad script does one thing for Firefox (and
<embed> only) and another thing for IE (an <object> with <params>).

So, it's the same problem... In this case, from what I can tell, the
error is being thrown when trying to appendChild() a <param> to an
<object>.

Even though it took me this long (well, a couple days, at least) to
narrow down the problem on this new ad, I'm kinda glad it's the same
bug (i.e. appendChild() to an <object>).

Hehe... Probably more info than anyone wants to know.

Noah, I've been playing with your idea and I have not had much luck so
far... Maybe I'm looking to patch things in the wrong spot(s)?

If you were me, would you be patching element.write or WC2? I've been
focusing on patching WC2 via the "writerFor()" function... Is this
where you would do it?

Sorry to be a bother... I'm just having some trouble making progress here. :(

Thanks!
Micky

noah

unread,
Oct 18, 2012, 9:07:52 PM10/18/12
to writecaptu...@googlegroups.com
I was thinking something like this ;)

https://github.com/iamnoah/writeCapture/commit/725976577a2d5744e62db726de57e65759b4f89a

That seems to work. Give it a shot and let me know.

Micky Hulse

unread,
Oct 18, 2012, 9:24:27 PM10/18/12
to writecaptu...@googlegroups.com
OMG, YOU DA MAN!

I have not tested yet, but I greatly appreciate the pro assist!!!!

I'll be testing ASAP and I'll get back to you as soon as possible with
my findings.

Oh, and I can safely say... I'd never had come close to writing such
an awesome patch. I wish I had 1/10th the JS skillz you have. :D

Many many thanks!!!! I'll be back!!!!

Cheers,
Micky
Reply all
Reply to author
Forward
0 new messages