I have a web page that contains two textboxes and a button. I can’t control this page by adding any thing to it, or changing any thing in it.
I want to (in some way) write some text in the first textbox when the page loads, without pressing the button.
I want to put the page in a frame and then control it from the container page
I know that I have to use jquery but I need a sample that explain that or to tell me how to do what I want
For example, if I have the file “a.htm”:
The content of “a.htm”:
<iframe id="frame1" src="f.htm" />
and the content of “f.htm” is:
<input type="textbox" id="tbx1" />
<input type="textbox" id="tbx2" />
<input type="submit" id="okbtn" value="ok"/>
For example, when the page “a.htm” loads, I want the textbox (“tbx1” for example) in the page “f.htm”, (contained in the frame “frame1”) to be filled by some text.
thanks in advance
Before I start on this answer, it’s worth explaining that you cannot use JavaScript alone to manipulate a frame which serves content from a separate domain*. In other words, if your page, a.htm, is on your domain (e.g. http://yourdomain.com/a.htm), and f.htm is on another domain (e.g. http://someothersite.com/f.htm), then JS will not be able to access anything inside the iframe.
*There are techniques available to do this, but as a rule of thumb they cause more trouble than good.
However, if it’s all on the same domain you should have no trouble. In
a.htm, to access the iframe, you could use the following jQuery snippet:So, your
a.htmcould look like: