I am using form post in my code ,I am printing the response to the iframe but I am not able to read the
response from I frame.
let iframeDoc = this.iframe.nativeElement.contentDocument; is coming null
<form #myFormId action="http://baseurl/login" method="post" target="load_data">
<label for="username">First name:</label>
<input type="text" id="username" name="username"><br><br>
<label for="password">Last name:</label>
<input type="text" id="password" name="password"><br><br>
<button (click)="check($event)">Click</button>
</form>
<iframe #load_data name="load_data" (load)="onIFrameLoad($event)" >
</iframe>
You can not read the content of iframe because of the security issue.
But you can communicate with an iframe using Window.postMessage API, please https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage for more information
If your parent application and application render in Iframe are not having the same origin (: :) then you wont be able to access the iframe content because of the security imposed by the browser.
If you can make ur iframe application to render from the same origin using proxy then you should be able to read the contentDocument property.
The more on this can be found at Cross Window Communication
Related
I am trying to post a dimple FORM in HTML as mentioned below:
<form name="myform" method="post" action="Home.html" onsubmit="return validateform()" >
<label class="labelText">
Name: </label>
<input class="textBoxName" type="text" name="name"><br/>
<label class="labelTextPassword"> <br/>
Password:</label>
<input type="password" name="password"><br/>
<input class="loginButton" type="submit" value="Login">
</form>
Its working successfully on my SYSTEM. but when I hosted my site on Azure, after validating name and password its not re-directing to "Home" Page. It shows error
as:
The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used. (Error: 405)
Can please anyone have any idea about this issue?
405 means Method not allowed.
It means that Home.html cannot accept a POST request
So try using the get method while sending the data and it would work.
I'm trying to open a form action url in a iframe which is in another html page.
I successfully opened it in a iframe which is on the same page with this code:
<form class="form" action="myConnexionURL" target="iframe-myAccount" method="post">
<input type="text" id="login" name="login" placeholder="ID">
<input type="password" id="pass" name="pass" placeholder="PSW">
<input type="submit" value="Connexion">
</form>
<iframe src="" name="iframe-myAccount"></frame>
So, my question is simple: How can I open the form action url in an iframe which is in another html page?
As far as I know, there is no way to access that iFrame directly. I think you'll have to pass the data to the parent and then have it adjust the URL for the embedded iFrame. I'd probably do this through server-side scripting, but you may be able to do it through JavaScript.
how can I place an iFrame around this form? On submit my button directs to a success page and I need it all to stay in one screen, hence incorporating an iframe. How can I achieve this? I've never used them before and adding <iframe> </iframe> tags around the form just makes it disappear.
Here's my form:
<form action="#link">
<input type="text" name="name" required placeholder="Enter your name"/>
<input type="email" name="email" required placeholder="Enter a valid e-mail address"/>
<input type="text" name="comment" required placeholder="Enter your comment"/>
<input type="submit" value="submit" />
</form>
If you place the form code, including the code to redirect to your success page in a separate document - usually PHP, then add the iFrame of that document where you want it.
An iframe is a tag that allows you to include a page inside another page. So, you have to link to another file, and you cannot put other tags inside it, as you tried.
To achieve what you need, you have to create a file, lets call it your_other_file.php, where you have the code of the form, and the code of the sucess page.
in your main page, you put something like this
<iframe width="800" height="600" src="your_other_file.php"></iframe>
depending of your purpose, you could prefer to send the form by ajax and update de div. but if you have no much experience, this approach is good enough.
A web server is running (on EC2) and I'm testing this simple Html5 login form with a method="post" attribute in two ways:
as-is
within a larger website
<div>
<form action="" method="post" >
<p/>
<input id="username" type="text" name="username" placeholder="Username" >
<p/>
<input id="password" type="password" name="password" placeholder="Password" >
<p/>
<input type="submit" class="btn" value="Login">
</form>
</div>
A handler in the Python-based web server includes:
username = self.get_argument('username')
password = self.get_argument('password')
The first method works with a Http 200 but the second generates a Http 405 "Method Not Allowed". Both use the identical handler code on the web server.
I cannot find where the problem is. What is the best way to debug this?
The problem was with the web-server and the order of the parameters/attributes for the Class function handling the Post method.
I'm playing with a new service's very simple API and I'm just curious if its possible to send an xml-rpc request directly from an html form. The api request example is this:
<?xml version="1.0"?>
<methodCall>
<methodName>send</methodName>
<params>
<param><value><string>YOUR_API_KEY</string></value></param>
<param><value><string>msg#mycompany.com</string></value></param>
<param><value><string>5551231234</string></value></param>
<param><value><string>Test Message from PENNY SMS</string></value></param>
</params>
</methodCall>
And my current form iteration is this:
<form method="POST" enctype="text/xml" action="http://api.pennysms.com/xmlrpc">
<input type="hidden" name="api_key" value="MYAPIKEY"/>
<label for="from">From</label>
<input type="input" name="from" value=""/>
<label for="phone">Phone</label>
<input type="input" name="phone" value=""/>
<label for="text">Text message</label>
<input type="input" name="text" value="">
<input type="submit" value="Send"/>
</form>
Not without involving either Javascript or server code. The "enc-type" attribute specifies the format that the form data is sent to the server in, and unfortunately "xml-rpc" isn't in the list of accepted formats :)
No, this is not possible from plain HTML. The only standard encodings for submitting form data are application/x-www-form-urlencoded and multipart/form-data.
You can do this from JavaScript using an XMLHTTPRequest, though only to APIs on the same domain that the HTML came from. After a quick Google search, I found this AJAX XML-RPC client, though I've never used it so I can't vouch for it.
That might depend if the server is actually enforcing the enctype
For example using the technique shown here http://pentestmonkey.net/blog/csrf-xml-post-request you can do cross-site posts of XML POST data.