none
IE9 RC - Error with script that worked on IE versions 4 - 8

    Question

  • I have a local script (stored in C:\Windows\Web\CopyTitleAndUrl_htm) that allows me to copy the title and URL of the current web page via a context menu entry (defined in the registry).  The script worked fine in previous version, but throws an error in IE9 RC.

    The script is:

    <!--
    Title_URL right-click context tool for IE4+
    Bill James - bill@billsway.com - rev 2 Nov 2000
    -->
    <form name=a><textarea name=a1></textarea>
    <SCRIPT language=javascript defer>
      //To disable popup confirmation, change "showConfirm=1" to "showConfirm=0"
      var showConfirm=0
      var oExtArgs=external.menuArguments;
      var sTitle=oExtArgs.document.title;
      if(sTitle=='')(sTitle='No Title');
      /*
        kludge - to keep newlines we must set text in
        textarea, then create textRange and copy that.
      */
      var oTarget=document.a.a1;
      oTarget.value=sTitle+': \r\n'+oExtArgs.location.href+'\r\n';
      oTarget.select();
      var oTextRange=oTarget.createTextRange();
      oTextRange.execCommand('copy');
      if(showConfirm)(oExtArgs.alert(oTarget.value+'\r\nCopied to Clipboard'));
    </SCRIPT>

    =======

    The error is:

    An error has occurred in the script on htis page

    Line: 18
    Char: 3
    Error: Unspecified error.
    Code: 0
    URL: file:///c:/windows/web/CopyTitleAndURL.HTM

    Any ideas on what is causing the error and how to fix it?

    Thanks,

    Eric

     

    • Moved by Yi Feng Li Monday, March 07, 2011 6:44 AM ie script issue (From:Internet Explorer Extension Development)
    Friday, March 04, 2011 3:03 PM

All replies

  • Hi,

    This forum is for IE addins, e.g. BHO, Band objects. Since your question about script, I'm moving this thread to IE Web Developing forum for better support.

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, March 07, 2011 6:43 AM
  • hi WEricBr,

    I recommend you post this issue to our Connect feedback portal. Our developer will evaluate them seriously and take them into consideration.

    Improving the quality of our products and services is a never ending process for Microsoft.

    thanks!

     

     


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com
    Microsoft One Code Framework
    Thursday, March 10, 2011 10:01 AM
    Moderator
  • I have a local script (stored in C:\Windows\Web\CopyTitleAndUrl_htm) that allows me to copy the title and URL of the current web page  

    Neat.   If nothing else you can use this much of it in the Address bar:

    javascript:title=document.title;url=location.href;title+"\r\n"+url

    I don't know why the CRLF doesn't work for output.  But it would be easy enough to just bang in an Enter instead after you Copy and Paste that much.   ; )

    BTW be careful in IE9 pasting javascript fragments into the Address bar; it eats the javascript protocol prefix!  A workaround is to press Ctrl-e, then paste your fragment, then delete the question mark; you don't even need to delete the separating space.  So the complete keyboard sequence for the workaround, assuming the above fragment is in your ClipBoard, would be:  Ctrl-e,Ctrl-v,Home,Delete,Enter, (pause for output), Ctrl-a, Ctrl-c, Backspace.   If that was important enough for me I could even reserve a function key for it and create an Intellitype macro with that much.   <eg>


    Thanks for the tip!

    Robert Aldwinckle
    ---

    Monday, March 21, 2011 9:44 PM
  • loose the defer statements...

    It is non standard and the browser interpretation of its use varies by vendor and IE version.

    search connect for 'defer'


    Rob^_^
    Tuesday, March 22, 2011 1:55 AM
  • What do you mean by defer statements?

    I'm a me too here?  I use this all the time when posting answers and would like to get it working again.

    Wednesday, March 23, 2011 5:07 PM
  • With EXTREME thanks to Ramesh Srinivasan

    Who posted up...

    Changing the following line:

    oTarget.value=sTitle+': \r\n'+oExtArgs.location.href+'\r\n';

    to

    oTarget.value=sTitle+': \r\n'+oExtArgs.document.URL+'\r\n';

    Makes it work in IE9/IE8 (and probably in earlier versions as well).

    Credits to Socrates (Soc) Trikes, IE MVP

    Friday, April 01, 2011 1:18 AM