www.webdeveloper.com
Results 1 to 3 of 3

Thread: Document.write function how to escape parametars

  1. #1
    Join Date
    Feb 2013
    Posts
    7

    Unhappy Document.write function how to escape parametars

    Hi guys,
    I have line like this and the onLoad function parameters are reporting error:
    Code:
    document.write("document.getElementById(\"my_iframe\").innerHTML = '<iframe src=\"http://MyDomain.com/index.php?accessing_from=\'+loc+\'\" style=\"border: none; min-height: 60px;\" onload=\"resizeCrossDomainIframe(\'iframe\', \'http://MyDomain.com\');\"> </iframe>'  ");
    The part that bothers me is
    Code:
    onload=\"resizeCrossDomainIframe(\'iframe\', \'http://MyDomain.com\');\"
    I get error with this setup but when I remove function parameters and leave it like resizeCrossDomainIframe() everything works OK (in terms of document writing, but function is not working as it's not passing parameters), so my question is why this won't work when parameters are escaped ?

  2. #2
    Join Date
    Mar 2011
    Posts
    1,108
    Why are you using 'document.write' to write JavaScript code in the first place?
    Rick Trethewey
    Rainbo Design

  3. #3
    Join Date
    Feb 2013
    Posts
    7
    OK, this is scenario. I want to host a script on my server and just give end users something like:
    <script src="https://MyDomain/MyScript.js"></script>
    and what that script does is creates iframe, fill it etc...

    Now I find this justifiable reason to do document write, right ? ...so how about a bit help on this.... is this doable at all ?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles