JavaScript Run Javascript in iFrame context javascript iframe content,javascript iframe contentwindow,javascript iframe contentdocument,javascript

I am attempting to run a script in a webpage, that should be executed in an <iframe>. Right now I can call a function that is set within the <iframe>.. I'm just having issues running a script to the <iframe>'s context.

Here's how I run a function set in the <iframe>

$('#iframe').get(0).contentWindow.performSearch();

Now instead of calling the preformSearch function, I wish to run a script - for this example, this is the script...

console.log('worked!');

My actual script is a big one, so I won't put it here - for the sake of this question.

So, is there any way to run that script through the <iframe>'s context? For example, my first guess would be/was..

$('#iframe').get(0).contentWindow.function(){
 console.log('worked!');
}

I've never messed with running functions through something like an <iframe> before though, so I'm stumped.

Thanks for any help in advance!

NOTE I am using NW.js (Node-Webkit) to remove all <iframe> restrictions.

NOTE v2 The preformSearch() function was just a reforence on how I call functions in the frame.

Answer:1

I started using html twig in Symfony2 and I got the following problem: function goEditConflict(){ $("#go").on("click", function(){ id = $("#case_number").val(); windows.location = {{ ...

I started using html twig in Symfony2 and I got the following problem: function goEditConflict(){ $("#go").on("click", function(){ id = $("#case_number").val(); windows.location = {{ ...

  1. parsing variable from javascript to php
  2. parsing variable in javascript
  3. parsing variable in java
  4. parsing parameters from url
  5. parsing variable in bash
  6. passing variable in sed
  7. passing variable in jquery
  8. passing variable in mysql
  9. passing variable in informatica
  10. parsing variable in xml

We used to be able to enter a search field, address on search box, hit the ENTER key on the keyboard and get the search results. I made several changes but can't pinpoint the change that resulted in ...

We used to be able to enter a search field, address on search box, hit the ENTER key on the keyboard and get the search results. I made several changes but can't pinpoint the change that resulted in ...

I made a code that should highlight searched string but it is not working. Here is the code: <body> <div>div is here</div> <div id="divid"> <div>this is a ...

I made a code that should highlight searched string but it is not working. Here is the code: <body> <div>div is here</div> <div id="divid"> <div>this is a ...

  1. select element with attribute
  2. select element with class
  3. select element with multiple classes
  4. select element with data attribute jquery
  5. select element with jquery
  6. select element with two classes
  7. select element with attribute jquery
  8. select element with javascript
  9. select element with text
  10. select element with class jquery
  11. select element with id css
  12. select element with child
  13. select element with class css
  14. select element with text css
  15. select element with two classes css
  16. select element with multiple classes css
  17. select element with id jquery
  18. select element with class javascript
  19. select element with data attribute javascript
  20. select element with id

I'm making some kind of pinterest backbone application. (post pics/vids/text etc to remember later) It is the first time I try to make a register/login in backbone. I have a homeView and an ...

I'm making some kind of pinterest backbone application. (post pics/vids/text etc to remember later) It is the first time I try to make a register/login in backbone. I have a homeView and an ...