I'm trying to run a javascript code via url to change values of the form in the page. Here is the content of the HTML page.
<html>
<body>
<form method='post'>
Name: <input type='text' id='name' value='' /><br />
Family: <input type='text' id='family' value='' /><br />
Email: <input type='text' id='email' value='' /><br />
<input type='submit' value='Submit' /><br />
</form>
</body>
</html>
Now, I enter the following value in the URL section of chrome:
javascript:document.getElementById('name').value = 'string1';
What happens is my whole page will go blank and only the value "string1" will be displayed in the page. However, running the following code works properly:
javascript:document.getElementById('name').value = 1;
It will change the value of the name field to 1. I'm wondering what is causing this problem.
Note: The purpose of this work is to inject code into webview in android.
Any advice is appreciated.