Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I am trying to refresh some div in my website dynamically.
//code changing the source
document.getElementById('#chatbox').src = document.getElementById('#chatbox').src; //refreshes the chatbox
alert("HERE");
The alert() function does not get executed after getElementbyId() is called.
What is going on?
You are trying to access src of undefined as there is probably no element with the id "#chatbox".
Remove the hash and it should work:
document.getElementById('chatbox').src
To debug take a look at your javascript error console or try
alert(document.getElementById('#chatbox')) // undefined
That's because it should be
document.getElementById('chatbox')
Perhaps you are confusing this with jQuery. With jQuery, you would use:
$('#chatbox')
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 8 years ago.
Improve this question
I've been looking at this for a long time now, and had several other people look over it. None of whom can spot what's causing this issue.
Something is causing the function validate() to be undefined by the time it gets to the body of the page. I belive there must be some error earlier in the program that is causing the browser to stop processing javascript before then, but I can't find it.
Full JS content:
http://pastebin.com/9b0pwktA
Any insight would be greatly appreciated
I fixed that code (at least visibility of validate method), by removing:
language="text/javascript"
from
<script language="text/javascript">
to make:
<script>
Try that out!
Edit...
There are numerous other bugs, but I targeted the specific problem the question was asking about.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I have an anchor element <a> and an image inside it. Both of them have JavaScript methods.
<img src="" onclick="someOtherMethod()">
Which Javascript function will be executed first, the function in the image onclick or the function in the link href?
The function inside the onclick attribute of the image will execute first.
You can observe this happening in this jsFiddle demo.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I'm probably doing something obviously wrong, but I just can't see it. I'm trying to use a for loop to define multiple click events and am experiencing an unexpected result. Some of this is working (the hide and show at the beginning of the function, but both sections wind up targeting the second item in the loop. Could somebody take a look at this and tell me what I'm doing wrong? Thank you so much for your help!
here is the link:
http://grana.us/test/expand2.html
You are assigning same event to all summaries for every id. This is wrong...
First... to hide all details and show all toglers simply use:
$('.details').hide();
$('.toggler').show();
And then define click function to all sumaries:
$('.summary').click(function(){
if($('.toggler',this).html() == ' -'){
$('.toggler',this).html(' +');
$('.details',$(this).parent()).hide();
}else{
$('.toggler',this).html(' -');
$('.details',$(this).parent()).show();
}
});
Put everything in...
$(function(){
...
});
and should be ok.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I found a nice site that build in ASP.NET. I want to try some things on it, like entering text into input field through console, with JavaScript, but it looks like it disabled. when I try to do:
document.getElementById("name");
I get null, on each element I try it. In the js files of site I see they are using getElementById in the code, but somehow it's disabled for me.
You need to use clientId. For example here is your server control
<asp:textbox id="txtName" runat="server/>
and now you want to access that with javascript then you need to do following.
document.getElementById("<%=txtName.ClientID%>").value;
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I am working on a clock which follows an ancient timekeeping at http://ancient-clock.stornge.com.
Right now Chrome has reported an error, but I'm not sure where it's coming from; Chrome says it cannot call a method on undefined, and the error message, in an HTML file containing JavaScript, is not near a line of JavaScript.
How do I identify the root cause when Chrome's debugger is not terribly helpful?
It's at line 20. You have to set a breakpoint to trace where the problem is at. You can even view/change all the variables in the right panel.
As you can see, summer_solstice is not defined.
Currently you are getting an error on the call to ANCIENT_CLOCK.summer_solstice.getTime() as ANCIENT_CLOCK.summer_solstice is not defined anywhere.
You do not have ANCIENT_CLOCK.summer_solstice or ANCIENT_CLOCK.winter_solstice defined.
And you are calling getTime() on both of these inside your ANCIENT_CLOCK.prepare_time function.