-1

I am making a chrome extension and I am loading a webpage using iFrame. But, I want all actions that come from it (ex. users click on a link, searches if there is searchbox) to go to with no iFrame (to leave the iFrame and load the other page normally).

other

Alternatives of this may be if I don't use any iFrame but div or something else to load the webpage on it.

Idrizi.A
  • 9,819
  • 11
  • 47
  • 88
  • I'm downvoting on this question because you deleted your question about cross-domain AJAX _whilst people were answering it_, which is poor etiquette. The question probably would have closed anyway, but you likely would have garnered hints towards a solution in the comments. Use JSONP, or use a script on your own server that connects to Amazon itself (a proxy script). – halfer Jan 26 '13 at 21:17
  • No problem about downvoting, I just need to know the way how to make a new request that will give me the data, thank you for telling me about JSONP – Idrizi.A Jan 26 '13 at 21:24
  • [This is useful](http://stackoverflow.com/a/11736771/472495) and look up [JSONP here](http://api.jquery.com/jQuery.ajax/). Use Firebug to see if your requests are successful, and if you have no luck, try a proxy script (it's easier than it sounds - you can use something like `file_get_contents()` for GET requests). – halfer Jan 26 '13 at 21:27
  • The JSONP is working and the request is made. IF I use proxy script I will need to create a PHP file that will take the data and give them to me. Am I right? – Idrizi.A Jan 26 '13 at 21:31
  • If the JSONP is working, my understanding is you don't need a proxy script. But if that doesn't work for whatever reason, then yes, a proxy script is exactly what you describe - you connect via AJAX to your own server and that script connects to Amazon. – halfer Jan 26 '13 at 21:32
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/23421/discussion-between-enve-and-halfer) – Idrizi.A Jan 26 '13 at 21:38
  • 1
    I just did what I wanted to do and it would have been much harder if you did not helped me – Idrizi.A Jan 26 '13 at 23:55

2 Answers2

1

You can use Javascript with the value top.location=<url> to break out of the iframe and load it in the URL bar.

Ryan Tse
  • 1,559
  • 11
  • 15
1

You should be able to add the permissions for the domain of the iframe to your extension's manifest and implement a content script for that domain as well.

Use the Google API for message passing to pass information between the content scripts for the two domains (since this is disallowed by the Same Origin Policy for normal pages)

See the message passing doc here

pclem12
  • 449
  • 10
  • 23
  • Yes, but, for ex., if I link google.com (which does not allow iFrame), the link wont work – Idrizi.A Jan 24 '13 at 22:23
  • you'll need to give more details, I'm not sure what you're trying to do. – pclem12 Jan 24 '13 at 22:48
  • I have an iFrame which contains a link of google.com. As you know google.com does not allow iframe. If the user clicks in that link which refers to google.com he will be refused by google because it will try to open google.com whithin an iFrame. – Idrizi.A Jan 24 '13 at 22:51
  • so send the link's url through message passing from the iframe to your outer page, and open the link from the outer page's content script – pclem12 Jan 24 '13 at 23:08