So I'm trying to make a table hidden when the webpage opens but when a is clicked it should show but I'm having problems with IE9. I read that IE8 and below do not support setAttribute and my webpage seems to work correctly with Firefox. Here is the code, just wondering if anyone could help me out:
<h1 onclick="myFunction()">Show Sitemap</h1>
<table id="myInput" style="visibility:hidden;" width="100%" height="50%">
<tr><td><p>Test</p></td></tr>
</table>
<script>
function myFunction()
{
document.getElementById("myInput").setAttribute("style","visibility:visible;");
};
</script>
Try using
function myFunction()
{
document.getElementById("myInput").style.visibility = "visible";
};
instead, as IE is more compatible with this.
Fiddle:http://jsfiddle.net/E396D/
I tried this in IE10 with compatibility mode on and it worked (the original didn't).
Related
I am trying to insert image inside a contenteditable div. Its working in chrome, firefox, opera and safari. But not working in Internet Explorer. I saw this post, it says insertImage works in IE. But I have no idea why its not working here. Will you please help me. Thank you.
html:
<button id="btn-insert_image">image</button>
<div id="content" contenteditable="true">
<p>How does it work? Just put your image size after our URL and you'll get a placeholder.</p>
</div>
js:
$(document).ready(function() {
$('#btn-insert_image').click(function() {
document.execCommand('insertImage', false, 'http://placehold.it/350x150');
});
});
jsfiddle
I have a code like below where
<script>
document.querySelector("#lor_show").innerHTML = $(".lor1").length;
</script>
lor1 value is from
<div class='lor1' id='unk'><td align='center'><font color='green'><b>UNKNOWN TYPE</b></font></td></div>
results go to
<td align='center' class=\"lor_show\" id=\"lor_show\"></td>
on Chrome everything works good but not in IE8 even when IE8 will work as DOC Mode IE8 Standard mode
Is there any reason why I'm not able to see object values from JavaScript using Firefox, but IE and Chrome see them without problem?
For example:
<div>
<input type="text" id="clientID" />
<input type="submit" id="search" value="Submit" class="submitButton" />
</div>
JavaScript:
<script type="text/javascript">
$(document).ready(function () {
$("#searchDisputes").click(function () {
if(clientID.value.toString() != "") {
//do something
}
}
}
</script>
Firefox tells me that clientID does not exist, however IE and Chrome work just fine.
I am able to access it using jQuery $("#clientID"), but before changing a good bit of code around, I would like to understand why this doesn't work in Firefox, but works ok in other browsers.
You are assuming that giving an element an id will create a global variable with the same name as the id containing a reference to the element. There is no reason browsers should do this.
document.getElementById("ctrl").disabled = true;
this works in IE but does not works in mozila. What shoul I do?
Did you try:
document.getElementById("ctrl").setAttribute('disabled', true);
<body>
<input id="btnSubmit" type="button" value="submit" onclick="disabled(this);"/>
<script>
function disabled(ctrl) {
ctrl.disabled = true;
}
</script>
</body>
It is hard to tell what the issue is that you are having. Does mozilla do anything when the code is executed? does it display an error? What version of ie did you test it with? And can you also provide the html for the ctrl element?
One of the issue with IE and the getElementById method is that in some versions of the browser it will match on the id attribute of a tag as well as the name attribute (which does not follow the JavaScript spec). In Mozilla it is only matching using the id attribute.
http://msdn.microsoft.com/en-us/library/ms536437(VS.85).aspx
So I have this in my RoR app, it works in FF, Chrome, and Safari... but not in IE7...
neither li works with or without javascript.
Why does this happen, and how do I fix it?
<li class="decline" name="javascript_required" style="display: none;">
Decline</li>
<noscript>
<li class="decline">
Decline</li>
</noscript>
Then I have this at the bottom
<script type="text/javascript">
hidden_links = document.getElementsByName("javascript_required");
for (i = 0; i < hidden_links.length; i++) {
hidden_links[i].style.display = "block";
}
</script>
Apparently, IE7 doesn't support getElementsByName.
Since I only had 3 things I needed to mess with, I used getElementById...
However.. with getElementById being used all the time would get nasty if there are a lot of things needing to be shown / hidden for whatever reason