I have html file with javascript code the contents of the file are as under: I tried this code on Safari and it was working fine. But when I tried this on Firefox, it’s not working. Can any one suggest how to make it working on firefox.
<html><head></head><body><button type="button" onClick="handleButtonClick();">undo</button> <button type="button">redo</button><select><option value="V1">V1</option><option value="V2">V2</option><option value="V3">V3</option><option value="V4">V4</option><option value="V5">V5</option></select> <script type="text/javascript">function handleButtonClick(){var xmlHttp, handleRequestStateChange; handleRequestStateChange = function() {if (xmlHttp.readyState==4 && xmlHttp.status==200) { var substring=xmlHttp.responseText; alert(substring); } }
xmlHttp = new XMLHttpRequest();xmlHttp.open("GET", "http://csce.unl.edu:8080/test/index.jsp?id=c6c684d9cc99476a7e7e853d77540ceb", true);xmlHttp.onreadystatechange = handleRequestStateChange; xmlHttp.send(null);}</script>
</body>
</html>
if you copy the above code to your system on clicking on undo button u will get the contents but the same code I am inserting through C++ as a string it is not working... what i figured out strange about the above code what that it required enter (return key) to be pressed before xmlHttp = new XMLHttpRequest(); othervise it was not working for html page also. The same thing I implemented in C++ code and the code is not working. The code is as under:
std::string login="<button type=\"button\" onClick=\"handleButtonClick();\">undo</button> <button type=\"button\">redo</button>< select><option value=\"V1\">V1</option><option value=\"V2\">V2</option><option value=\"V3\">V3</option><option value=\"V4\">V4</option><option value=\"V 5\">V5</option></select> ";
std::string jscriptstring1="<script type=\"text/javascript\">function handleButtonClick(){var xmlHttp, handleRequestStateChange; handleRequestStateChang e = function() {if (xmlHttp.readyState==4 && xmlHttp.status==200) { var substring=xmlHttp.responseText; alert(substring); } }";
std::string jscriptstring2="xmlHttp = new XMLHttpRequest();xmlHttp.open(\"GET\", \"http://csce.unl.edu:8080/test/index.jsp?id=c6c684d9cc99476a7e7e853d77 540ceb\", true);xmlHttp.onreadystatechange = handleRequestStateChange; xmlHttp.send(null);}</script>";
std::string ret="\n";
login+=jscriptstring1;
login+=ret;
login+=jscriptstring2;
Please can any one suggest what is going wrong?