What causes the wrong syntax in these scripts in IE?

24 views
Skip to first unread message

Edgar Javison

unread,
Oct 10, 2006, 8:38:15 AM10/10/06
to Tiddl...@googlegroups.com
Here I go again.  I'm just having this concern because two of the scripts in my TW are being declared by IE as "wrong syntax" but they run fine in Firefox.

<script>
<!--
drawTREmbed( '<div id="technorati">' +
'<img src=\"http://static.technorati.com/progimages/photo.jpg?uid=363456\ " alt=\"edgej\'s Photo\" id=\"te_p\" style=\"float:left;padding:0 5px 3px  0;width:40px;height:40px\" />' +
'<p id="te_l" class="te_l">' +
'</p>' +
'<p id="te_lo" class="te_lo"><a href="http://www.technorati.com/?cc=y7n4ruq9mj"><img border="0" src=" http://static.technorati.com/pix/tn-tiny.gif" alt="Powered by Technorati" /></a></p>' +
'</div>'
);
function drawTREmbed(s){
    document.write(s);
}
// -->
</script>

The other one is:

<script>
<!--
if(typeof(mbl_jsserv_loaded) == 'undefined') {

function m_r_e(obj, w, f) {
  if(window.addEventListener ){ obj.addEventListener(w, f, false); }else if(window.attachEvent){ obj.attachEvent('on'+w, f); }else{}
}
function m_rm_e(obj, w, f) {
  if(window.addEventListener){ obj.removeEventListener(w, f, false); }else if( window.attachEvent){ obj.detachEvent('on'+w, f); }else{}
}
function m_i_eu(url){
  if(!url){return false;}
  if(typeof(url)!='string'){return true;}
  url=url.toLowerCase();
  if(url.indexOf('https://')==0){url= url.substring(8);}
  else if(url.indexOf('http://')==0){url=url.substring(7);}
  else if(url.indexOf('ftp://')==0){url = url.substring(6);}
  else if(url.indexOf('ssl://')==0){url = url.substring(6);}
  else if( url.indexOf('mailto:')==0){return true;}
  else{return false;}
  if(url.indexOf('www.')==0){url=url.substring(4);}
  var hn=document.location.hostname.toLowerCase();
  if(hn.indexOf('www.')==0){hn=hn.substring (4);}
    if(hn==''){return true;}
  if(url.indexOf(hn)!=0){return true;}
  return false;
}

    var cs_mbl_isAOL_V8 = false;
    if(navigator.userAgent.indexOf('AOL 8.0') > 0){ cs_mbl_isAOL_V8 = true; }   
    var cs_mblID='2006090718354540', cs_url_trker='http://track2.mybloglog.com/tr/urltrk.php', mbl_isi='N2006091606593257', mblco_on='', mblco_pu='', mblco_n='', mblco_e='', mblco_u='', mblco_c='';
    function m_p_c(obj, flag){
      for(var j=0;j<=5;j++){if(flag==1){if(obj&&obj.nodeName.toUpperCase()=='A'){return obj;}}if(flag==2){if(obj&&obj.nodeName.toUpperCase()!='BODY'&&obj.onclick){return obj;}}if(!obj.parentNode){return null;}obj= obj.parentNode;}
      return null;
    }
    function m_is_u(s){
    if(!s){return false;}
        var regexp = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i
        return regexp.test(s);
    }
  function m_trim(str, ch){
    while(str.substring(0,1)==ch){str=str.substring(1, str.length);}
    while(str.substring(str.length-1, str.length)==ch){str = str.substring(0, str.length-1 );}
    return str;
  }
    function m_ctx_c(e){
      var tg = null;if(e){tg=e.target;}else{tg=window.event.srcElement;}m_d_t(tg, false);
    }
    function m_oclk(e){var tg=null;if(e){tg=e.target;}else{tg= window.event.srcElement;}m_d_t(tg, true);}
    function m_d_t(tg, delay){
      var url=null, text=null, co_qstr='';
      try{
        if(tg){
          tgP=m_p_c(tg, 1);
          if(tgP&&tgP.nodeName.toUpperCase()=='A'){tg=tgP;}
          if(tg.nodeName.toUpperCase()=='A'){url=tg.href;if(tg.innerHTML){text=tg.innerHTML;}else if(tg.innerText){text=tg.innerText;}else if(tg.text){text=tg.text;}else{}}
        else if(tg.nodeName.toUpperCase()=='AREA'){url= tg.href;text=tg.getAttribute('alt') ? tg.getAttribute('alt') : tg.getAttribute('id');if(text==null||text==''){text=url;}}
        else if(tg.nodeName.toUpperCase()=='INPUT'&&tg.type.toUpperCase()=='SUBMIT'){url=m_trim( tg.form.action,'/');url=m_trim(url,' ');text=tg.value;
          }else{}
          if(url==null||text==null){return true;}
          if(co_qstr!=''||m_i_eu(url)){if(cs_mbl_isAOL_V8 && (tg.target=='_new'||tg.target=='_blank' )){return true;}url=escape(url);text=escape(text);m_trk(text, url, co_qstr, delay);}
        }
      }catch(err){}
    }
    function m_trk(text, url, co_qstr, delay){     
      try{
        var now=new Date();var trackURL=cs_url_trker+'?t=2&u='+url+'&te='+text+'&i='+cs_mblID+'&now='+now.valueOf()+'&d=20060916'+'&db=db3'+'&v='+mbl_isi+co_qstr;var x= document.createElement('IMG');x.src=trackURL;if(delay){m_pse(900);}
      }catch(err){}
    }       
    function m_t_ol(){
      try{
        var now = new Date();
        var url = escape(document.location.href );
        var ext_referrer=document.referrer;
        if(ext_referrer!=''&&m_i_eu(ext_referrer)){
          var ext_referrer_para='&eref='+escape(ext_referrer);
        }else{var ext_referrer_para='';}
        var trackURL = cs_url_trker + '?i=' + cs_mblID + '&t=1&u=' + url + '&a=' + escape(navigator.userAgent) + '&d=20060916' + ext_referrer_para + '&db=db3' + '&now=' + now.valueOf() + '&v=' + mbl_isi;
        var x=document.createElement('IMG');x.src=trackURL;   
      }catch(err){ }
      return true;
    }
    function m_pse(numberMillis){var now=new Date();var exitTime=now.getTime()+numberMillis;while(true){now=new Date();if( now.getTime()>exitTime){return;}}}

  //start IFrame ad tracking
  //from http://www.digitalmediaminute.com/article/1715/adsense-click-pepper
    var m_px=0,m_py=0,m_as_frms=new Array(),is_ie=document.all?true:false;
    function m_as_init() {
        var ad=document.getElementsByTagName('iframe');
        for(var i=0;i<ad.length;i++) {
      if(ad[i].src.indexOf(' googlesyndication.com')>-1){
        m_as_frms[m_as_frms.length]=new Array(ad[i], 'http://pagead2.googlesyndication.com', 'Google AdSense');
        if(is_ie){ad[i].onfocus=m_trk_as;}
      } else if(ad[i].src.indexOf('ypn-js.overture.com') > -1) {
        m_as_frms[m_as_frms.length]=new Array(ad[i], ' http://ypn-js.overture.com', 'Yahoo! Publisher Network');
        if(is_ie){ad[i].onfocus=m_trk_as;}
      } else {}
    }
    if(m_as_frms.length>0&&!is_ie){m_r_e(window, 'beforeunload', m_as_ul);m_r_e(document, 'mousemove', m_gm);}
    }
    function m_gm(e) {
        if(!e){var e=window.event;}
        if(e.pageX||e.pageY){m_px=e.pageX;m_py=e.pageY;}
        else if(e.clientX||e.clientY){ m_px=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft ;m_py=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;}
    }
    function m_gpos(obj) {
        var curleft = curtop = 0;
        if(obj.offsetParent) {
            curleft=obj.offsetLeft ;
            curtop=obj.offsetTop;
            while(obj=obj.offsetParent){curleft+=obj.offsetLeft;curtop+=obj.offsetTop;}
        }
        return [curleft,curtop];
    }
    function m_as_ul(e) {
    try{
      var m_as_size='';
            for(var i=0;i<m_as_frms.length;i++) {
        var ad_pos=m_gpos(m_as_frms[i][0]);
                var a_fx=(m_px>(ad_pos[0]-10)&&m_px<(parseInt(ad_pos[0])+parseInt(m_as_frms[i][0].width)+15));
                var a_fy=(m_py>(ad_pos[1]-10)&&m_py<(parseInt(ad_pos[1])+parseInt(m_as_frms[i][0].height)+10));
                if(a_fx&&a_fy){m_trk_as(m_as_frms[i][0]);break;}
            }
        }catch(err){}
    }
    function m_trk_as(f){
    try{
        if(!f&&window.event.srcElement){var f=window.event.srcElement;}
        for(var i=0;i<m_as_frms.length;i++) {
          if(m_as_frms[i][0]==f) {
            var a_si = m_as_frms[i][0].width + 'x' + m_as_frms[i][0].height;
            m_trk(escape(m_as_frms[i][2]+' ('+a_si+')'), escape(m_as_frms[i][1]+'#'+a_si), '', true);break;
          }
        }
        if(is_ie){window.focus();}
        }catch(err){}
    }
  //end IFrame ad tracking

    if(document.body){//if the script is inside the body tag - which it should be
      document.body.onclick = m_oclk;
      document.body.oncontextmenu = m_ctx_c;
    }else if(document){//script is outside the body tag - works in some browsers
      document.onclick = m_oclk;
      document.oncontextmenu = m_ctx_c; 
    }else{} 
    m_t_ol();
  m_r_e(window, 'load', m_as_init);
 
 var mbl_jsserv_loaded = true; 
}
// -->
</script>

All of these sound Greek to me.  I just copied the script from the originating sites and put them in separate tiddlers, as earlier advised by Eric.   I just don't know if this "syntax error" was already detected by IE prior to the release of TW 2.1 because it is only now that I have decided to check how my TW looks in IE.

--
Edgar Javison

We are each of us angels with only one wing, and we can only fly by embracing one another.  ~ Luciano de Crescenzo

Kalle Alm

unread,
Oct 10, 2006, 11:30:10 AM10/10/06
to Tiddl...@googlegroups.com
On Tue, 2006-10-10 at 20:38 +0800, Edgar Javison wrote:

> <script>
> <!--
> drawTREmbed( '<div id="technorati">' +
> '<img src=
> \"http://static.technorati.com/progimages/photo.jpg?uid=363456\" alt=
> \"edgej\'s Photo\" id=\"te_p\" style=\"float:left;padding:0 5px 3px
> 0;width:40px;height:40px\" />' +

Long shot, but you're escaping the "'s in the above (starting at '<img
src=\"htt...) which is not necessary as your string delimiter is
apostrophe ('). Don't know if IE whines about that but it might.

-Kalle.

Eric Shulman

unread,
Oct 10, 2006, 11:51:18 AM10/10/06
to TiddlyWiki
The first script is simply writing static HTML into the document. You
can skip the code entirely and just embed the HTML directly...

<html>
<div id="technorati">


<img src="http://static.technorati.com/progimages/photo.jpg?uid=363456"
alt="edgej's Photo"
id="te_p"
style="float:left;padding:0 5px 3px 0;width:40px;height:40px" />

<p id="te_l" class="te_l">

</p>


<p id="te_lo" class="te_lo">
<a href="http://www.technorati.com/?cc=y7n4ruq9mj">

<img src="http://static.technorati.com/pix/tn-tiny.gif"
border="0"


alt="Powered by Technorati" />
</a>
</p>

</div>
</html>

HTH,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

Edgar Javison

unread,
Oct 10, 2006, 12:43:46 PM10/10/06
to Tiddl...@googlegroups.com
Thanks Kalle Alm, but Eric's solution works!  Thanks again, Eric.

Now it's down to the second script.... It still shows up as a syntax error in IE.


On 10/10/06, Eric Shulman <elsd...@gmail.com> wrote:

The first script is simply writing static HTML into the document.  You
can skip the code entirely and just embed the HTML directly...



Justin Case

unread,
Oct 12, 2006, 12:42:39 AM10/12/06
to TiddlyWiki
Edgar Javison wrote:
> Now it's down to the second script.... It still shows up as a syntax error
> in IE.

I'm not sure about that second script. Here's what I've found, though.

First, it seems you found an IE bug in TiddlyWiki 2.1.2. There is a fix
that will work. But since you're using the tiddlyspot -- you're going
to have to make the changes on disk and then upload.

Using a good text editor (not Notepad), open up your *.html TiddlyWiki
file. Search for the following function:

function refreshElements(root,changeList)

below that is the code:

if(e.getAttribute)
type = e.getAttribute("refresh");
else
type = null;

You need to change it to:

if(e.getAttribute && e.tagName != "IFRAME")
type = e.getAttribute("refresh");
else
type = null;

The reason is that IE throws a permission denied error. I'm guessing
that the real fix that gets put in might be a bit different (it may
catch the error instead). But this fix does work.

-----

You also found an IE error in the ReminderMacro plugin. Once you fix
the above error, you can fix this one while using the TiddlyWiki -- in
Firefox or IE. Just edit the ReminderMacro plugin and you'll find
towards the top of the Code section, lines like:

// This line is to preserve 1.2 compatibility
if (!story) var story=window;

This is the line causing an error in another plugin (HaloscanMacro).
Since TiddlyWiki 2.1.2 defines story itself, this line isn't needed for
any 2.1.x version. Change it to:

// This line is to preserve 1.2 compatibility
// if (!story) var story=window;

and that will fix your other problem.

-----

These 2 changes are all I could find. If you know of another other
types of IE errors, please let me know what I need to click on to
produce them. Thanks!

Justin Case

unread,
Oct 12, 2006, 1:18:42 AM10/12/06
to TiddlyWiki
That second script -- I finally found it. It's in your MyBlogLogScript
tiddler. There's 2 lines you need to get rid of:

<!--

and

// -->

That's right -- it's the comments that's screwing it up in IE.

-----

Also, my previous post -- I was viewing http://elj.tiddlyspot.com/ and
noticed those errors in IE. The errors occur when the page is first
loaded and also on a page reload.

Simon Baird

unread,
Oct 12, 2006, 4:05:27 AM10/12/06
to Tiddl...@googlegroups.com
On 10/12/06, Justin Case <bla...@gmail.com> wrote:

You need to change it to:

               if(e.getAttribute && e.tagName != "IFRAME")
                       type = e.getAttribute("refresh");
 
The permission denied error is one I've come across a few times mostly in relation to google adsense in a TiddlyWiki. It had me stumped. Very happy to have a solution. Hope this gets into the core soon. Thanks!!!!
 
Regards,
Simon.
 
 

Edgar Javison

unread,
Oct 12, 2006, 6:42:46 AM10/12/06
to Tiddl...@googlegroups.com
Thank you very much, Justin!  Now, my TiddlyWiki works both in Firefox and IE!

Justin Case

unread,
Oct 12, 2006, 5:58:36 PM10/12/06
to TiddlyWiki
On Oct 12, 4:05 am, "Simon Baird" <simon.ba...@gmail.com> wrote:

> On 10/12/06, Justin Case <blaz...@gmail.com> wrote:
> >
> > You need to change it to:
>
> > if(e.getAttribute && e.tagName != "IFRAME")
> > type = e.getAttribute("refresh");
>
> The permission denied error is one I've come across a few times mostly in
> relation to google adsense in a TiddlyWiki. It had me stumped. Very happy to
> have a solution. Hope this gets into the core soon. Thanks!!!!

Well, I really think that a try/catch solution would be better. Have I
mentioned how much I love Google Groups Beta? Anyway, check this quick
try/catch test out. If you don't have IE, you can use Firefox. I
haven't tested Safari or Opera yet. Just point your browser to:

http://groups-beta.google.com/group/TiddlyWiki/files?

and then click on the JustinCase_tryCatchTest.html file (or right click
and Save Link As...). Anyway, you can test it locally or right from
Google Groups Beta.

The solution I was testing for in that file would be:

try
{


type = e.getAttribute("refresh");
}

catch(ex)
{
type = null;
}

Jeremy Ruston

unread,
Oct 15, 2006, 5:22:35 PM10/15/06
to Tiddl...@googlegroups.com
> The permission denied error is one I've come across a few times mostly in
> relation to google adsense in a TiddlyWiki. It had me stumped. Very happy to
> have a solution. Hope this gets into the core soon. Thanks!!!!

I've added a ticket for this issue:

http://trac.tiddlywiki.org/tiddlywiki/ticket/204

Cheers

Jeremy

--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com

Reply all
Reply to author
Forward
0 new messages