Current location: Hot Scripts Forums » General Web Coding » JavaScript » Iframe Access Denied on window.open


Iframe Access Denied on window.open

Reply
  #1 (permalink)  
Old 09-28-08, 05:28 PM
sharijl's Avatar
sharijl sharijl is offline
Newbie Coder
 
Join Date: Nov 2005
Location: North Carolina
Posts: 86
Thanks: 1
Thanked 1 Time in 1 Post
Iframe Access Denied on window.open

I have one Iframe named "ticket" and I want to use it for two different actions. My onsubmit action calls the iframe and does some other things.

Code:
 
            ticketwin = document.getElementById("ticket");
            page = ticketwin.contentWindow.document;
            doc.open();
            var compiledtext;
            with(doc){
            compiledtext = "<FONT SIZE=4>Ticket: " + form.MDN.value + "</FONT>";  
                        writeln(compiledtext);
            }
            doc.close;
This works fine except after I have executed this onclick action:

Code:
function ChangePage(Opt_List) 
           { 
           var number = form.MDN.value;
           window.open("http://page.com/Query.do?MDN=" + number, "ticket"); 
           }
If I do this first then I get a Javascript error "Access Denied" performing the onsubmit action.

first script compiles some code and prints it out in the iframe and the other code takes a variable and uses it to query another page in the same iframe. It seems these two conflict on the window.open because after I open the link in the frame I can't get control of the frame again to print the text. It works fine if I have two seperate iframes but I don't want that. Any ideas?
Reply With Quote
  #2 (permalink)  
Old 09-29-08, 01:21 PM
Dwagar's Avatar
Dwagar Dwagar is offline
Newbie Coder
 
Join Date: Sep 2008
Location: Ohio
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Is the page your referencing in the iframe contain javascript that might be referencing the perant window.

The error means there is javascript being reference across a different domain, if everything is on the same domain (.com) it should work.

When I reference an iframe before I did

ticket.document.location.href='url'

instead of window.open, not sure which one is more efficient.

I hope this helps ou out.
Reply With Quote
  #3 (permalink)  
Old 09-29-08, 03:46 PM
sharijl's Avatar
sharijl sharijl is offline
Newbie Coder
 
Join Date: Nov 2005
Location: North Carolina
Posts: 86
Thanks: 1
Thanked 1 Time in 1 Post
That's it

The page is accessing a different server and that is crazy that Javascript can not go back and forth like this, but your incite on the error gave me the path the the solution.

I created a PHP page on my server with an iframe linking to the external server's page. Using PHP I grabbed the variable and echoed it into the iframes src and it works like a charm.
Reply With Quote
  #4 (permalink)  
Old 10-01-08, 09:15 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
It's not crazy as it's for security reasons. If cross-domain access was allowed, I could easily craft a script which grabs say session data from all users on a site, or even create a keylogger, and then sends all gathered data to my own site. Given that I can inject it on your site or one accessed via it.

Yes, you'll have to use a serverside script to "bounce" off-site access, as you can have greater control that way.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Warning: mysql_query() [function.mysql-query]: Access denied for user 'mylogi'@'localhost' (using pa tut123408 PHP 6 05-27-08 11:50 PM
Iframe doesn't load a page, gives access denied error. swapcool JavaScript 1 08-29-07 01:16 PM
cross server error: access is denied kuraiza JavaScript 1 03-14-06 01:31 PM
Sql Server does not exists or access denied error. pdnitin ASP.NET 2 11-15-04 12:06 AM
Permission denied when access excel obj msrnivas ASP.NET 0 12-05-03 02:18 AM


All times are GMT -5. The time now is 11:44 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.