Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: VML: script injection causes IE to fail on if (!document.namespaces) #27

Open
maranomynet opened this issue May 22, 2009 · 6 comments

Comments

@maranomynet
Copy link

If your page contains a few images that delay the window.onload event slightly, the following code will trigger the error:

<script>
  var script = document.createElement('script')
  script.src = '/cufon.js';
  document.body.appendChild(script);
</script>

This seems to be a known bug, with a really ugly workaround (see:
http://groups.google.com/group/Google-Maps-API/browse_thread/thread/3c63eb14c45fad9c)

I wonder if one could avoid having the error occur at load time - by delaying the execution of the function checking the document.namespaces until the first time the user calls Cufon.replace...

...or doing try-catch with a window.onload fallback...

...just a thought.

@sorccu
Copy link
Owner

sorccu commented May 23, 2009

An even more serious problem is probably the use of document.write(). While it would be possible to make cufon.js work without it, I don't really see the point. One possible use case may be loading cufon only for browsers that do not support @font-face, but you'd almost certainly experience a delay if you loaded cufon.js that way.

@maranomynet
Copy link
Author

I've added the xmlns:v="urn:schemas-microsoft-com:vml namespace attribute and a strict doctype - and my dynamically loaded Cufon init script works beautifully in IE when I browse between pages - but the font replacement does not occur when I hit Ctrl-R or the Reload button.

It has me stumped at the moment. ...Arrr!

@maranomynet
Copy link
Author

Update: It seems that three things are needed for sorry old MSIE 8 >:

  1. adding xmlns:v="urn:schemas-microsoft-com:vml namespace to the <head/>
  2. Strict <!DOCTYPE>
  3. Hard-coded <script> link to the Cufon script.

Bottom-line: lazy-loading cufon seems impossible in MSIE 8 >

@mdumic
Copy link
Contributor

mdumic commented Feb 15, 2012

This should be rechecked again since #232 introduced support for asynchronous (delayed) loading.

@amatecha
Copy link

I'm not sure that the commit #232 fixes the issue. In IE9, I get an "unspecified error" here:

var ns = document.namespaces;

(line 967 in current latest version)

I assume this is a symptom of the same issue as above, but I could be missing something here as I'm no JS expert. I am using deferred loading on my site, basically using this guy's technique (his first example): http://stackoverflow.com/a/5853358

Let me know if you need more info to help debug this issue (or let me know if I'm missing something super obvious).

Oh, oddly enough, refreshing the page makes the error magically no longer occur, and the font-replacement proceeds as usual. :P

@mdumic
Copy link
Contributor

mdumic commented Mar 29, 2012

@amatecha I'd like to get to the bottom of this. Can you prepare a minimal test case, just one html file (and CSS/JS as needed) with everything in it and create a gist? You can use "Vegur" font and omit it from your file as it is part of this project already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants