Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Error when using window.document.title

    I have some javascript that I am executing from a Silverlight app written in Delphi Prism. I'm pretty sure it didn't use to get InvalidExceptions, but now it does.

    What this javascript is supposed to do is open a window and the uri will be a path to a document/image. And set the title.

    Here is the code:

    method DocumentsDialog.OpenNewWindow_Click(sender: System.Object; e: System.Windows.RoutedEventArgs);
    var
    selectedItem : FileString;
    javascriptOpenWindow : String;
    openString : String;
    begin
    selectedItem := FileString( dataGrid1.SelectedItems[0] );

    openString := DownloadUriString( selectedItem );

    javascriptOpenWindow := 'var win = window.open( ''' + openString + ''',''_blank'', ''' + windowOptions + ''' ); win.document.title=''' + HttpUtility.HtmlEncode( selectedItem.Filename.ToString ) + ''';';
    try
    HtmlPage.Window.Eval( javascriptOpenWindow );
    except
    on Ex : Exception do begin
    if Ex is InvalidOperationException
    then // do nothing
    else raise;
    end;
    end;
    end;

    Apparently it is the win.document.title that is causing the problem. The window DOES open up.

    It works fine in Firefox. Certain IE versions in certain environments are causing the problem.

    Anybody got a clue why it is sometimes causing a problem? Could there be some setting difference, or some local policy that is creating the error even when it does open the window?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,017
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    Quote Originally Posted by mtiede View Post
    It works fine in Firefox. Certain IE versions in certain environments are causing the problem.

    Anybody got a clue why it is sometimes causing a problem? Could there be some setting difference, or some local policy that is creating the error even when it does open the window?

    Suppose you tell us which versions of IE in which environments cause the problem?

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Some customers have reported having the problem in IE 7. Don't know their OS. I used the Win7 Virtual XP box with IE 8 and got the problem. I think others with IE 8 say it is okay.

    I'm hoping someone has seen this problem before and has a suggestion independent of IE and OS versions. That would give me a starting point.

  • #4
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    At least, IE 8 running in the Win XP virtual box on Win7 exhibited the problem.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •