Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have implemented a dynamic webpage whose content worked as per parameters set in URL inside an . in the content of the page we have a form which has jQuery based validation, collection of form data in an object and submission of data to there server using AJAX. looks pretty simple and decent.

The problem is that the jQuery script which is called in the page (which is inside iFrame) is not working properly. but if I load the jQuery by searching it in the webpage elements in chrome debugging tool and open it from there in separate tab by clicking on "open in new tab" from context menu, same jQuery based script related position start working when checked from console without reloading the page.

example: there is a variable in jQuery based script formObj, when I am trying to access its content from console, console returns an error saying "
Uncaught ReferenceError: formObj is not defined
" but when I go to "Element" tab in chrome dev tool, search for my script "vendor.js", right click on it and press "open in new tab" from context menu. and then click back on "console" and try to access same object without any reload of page, i.e. by typing
formObj 
in console, I am getting the result. as shown in image below

Image 1
Image 2

What I have tried:

I have tried a lot of things including changing context as mentioned on lot of forums. I didn't found someone facing exact issue. Its weird but beyond logic.
Posted
Updated 7-Dec-20 1:29am
v3

1 solution

When you execute commands in the developer console, they run in the top-level window by default. If you want to run the commands in the context of an <iframe> within the page, you need to select that frame from the Javascript Context dropdown list:

Select JavaScript context | Console Reference | Chrome DevTools | Google Developers[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900