Java Scripts some Problems
How do I redirect to another webpage in Java Script?
return redirect through java script
// similar behavior as an HTTP redirect
window.locate.replace("http://learninginz.com");
// similar behavior as clicking on a link
window.locate.href("http://learninginz.com");
window.location.replace(...)
is better than using window.location.href
, because replace()
does not keep the originating page in the session history
Enable/Disable a dropdownbox in jquery
Disable dropdown list selection in jquery
$(document).ready(function() {
$("#ID").prop("disabled", true); // for disable
$("#ID").prop("disabled", false); // for enable
});
-------------------------------------------------
$(document).ready(function() {
$("#ID1").click(function() {
if ($(this).is(":checked")) {
$("#ID").prop("disabled", true);
} else {
$("#ID").prop("disabled", false);
}
});
});
How to refresh a page with jQuery
<!DOCTYPE html>
<html>
<head>
<title>Refresh with JavaScript</title>
<script>
function reloadPage(){
location.reload(true);
}
</script>
</head>
<body>
<button type="button" onclick="reloadPage();">Reload page</button>
</body>
</html>
How to get text from dropdown in javascript ?
var skillsSelect = document.getElementById("newSkill"); //Dropdown ID var selectedText =
skillsSelect.options[skillsSelect.selectedIndex].text;
alert(selectedText );
through JQuery
$("#yourdropdownid option:selected").text();
how to clear / splice array in javascript
dataPackages.splice(0, dataPackages.length)
Make the entire document editable:
On browser console
document.designMode = "on";
document.designMode = "off";
HTML DOM contentEditable Property
1 - document.getElementById("myP").contentEditable = "true";
2 - element.contentEditable = 'true'
'true
' indicates that the element is contenteditable
.
'false
' indicates that the element cannot be edited.
'inherit
' indicates that the element inherits its parent's editable status.