sandersyao / jqueryrotate

Automatically exported from code.google.com/p/jqueryrotate
0 stars 0 forks source link

Throws error when page contains no 'HEAD' element #102

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
  1. Right-Click any image on a webpage
  2. Choose 'Open image in new tab'

What is the expected output? What do you see instead?
  Plug-in should load normally,
  Instead shows error found, 'No property "style" of undefined'

What version of the product are you using? On what operating system?
  v2.3, in Chrome 29.0.1547.66, on Win7 64bit

Please provide any additional information below.

May not be fixable since the information you get from 'head' is needed to 
detect what browser is being used. But I thought I'd mention it anyways.

I got the script to run perfectly for my needs by just setting the vars to what 
would have been detected for Chrome.

Thank you for the wonderful plugin!

Original issue reported on code.google.com by neoj...@gmail.com on 10 Sep 2013 at 11:15

GoogleCodeExporter commented 9 years ago
Well I tried to reproduce on mine chromium but without any succes. Do you have 
any page where I can see the problem live ? 
Thanks in advance

Original comment by wil...@gmail.com on 17 Sep 2013 at 11:16

GoogleCodeExporter commented 9 years ago
Unfortunately I have no live examples. I wrote a little script for my own use 
and run it through Tampermonkey.

Here is a link my script would run on though - 
http://lebojct.com/Swift-N-Sure/5-11-13-CarWash/images/01.jpg

If you inspect the page using Chrome you see -

<html>
    <body style="margin: 0px;">
        <img style="-webkit-user-select: none" src="http://lebojct.com/Swift-N-Sure/5-11-13-CarWash/images/01.jpg">
    </body>
</html>

There is a <BODY> element, but there is not a <HEAD> element.

So the plugin breaks around line 10 running the code -
styles = document.getElementsByTagName("head")[0].style

There is no <head> element, so document.getElementsByTagName("head") returns 
null, and then the plugin stops when trying to execute .style on null.

Original comment by neoj...@gmail.com on 17 Sep 2013 at 10:38

GoogleCodeExporter commented 9 years ago
Ahh hmm ok now i get it :) Still it's weird as a <head></head> element should 
be created internally in browser even if not defined explicite, I need to 
investigate a bit more. Thanks for finding

Original comment by wil...@gmail.com on 18 Sep 2013 at 7:37

GoogleCodeExporter commented 9 years ago
Ahh I get it, you're using it as/trough extension - in that case a normal 
global context might be slighty different. Still there should be other,easy way 
to append styles crossbrowse mhmm..

Original comment by wil...@gmail.com on 18 Sep 2013 at 7:39