For instance in the snippet below - how do I access the h1 element knowing the ID of parent element (header-inner div)?
<div id='header-inner'>
<div class='titlewrapper'>
<h1 class='title'>
Some text I want to change
</h1>
</div>
</div>
Thanks!
...
I am using Ruby on Rails.
I want to create a filter field on a page such that whenever the input field's value changes I filter a list shown below via ajax. (Exaclty like the Users search works in Stackoverflow)
For now, I made it run with a form_remote_tag containing a text_field_tag and a submit_tag, and it filters my list when I pus...
What is most concise/efficient way to find out if a javascript array contains an obj?
This is the only way I know to do it:
contains(a, obj){
for(var i = 0; i < a.length; i++) {
if(a[i] === obj){
return true;
}
}
return false;
}
Is there a better/more concise way to accomplish this?
This is very closely related t...
The jQuery documentation says the library has built-in support for the following events: blur, focus, load, resize, scroll, unload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, keyup, and error.
I need to handle cut, copy, and paste events. How be...
Steve Yegge recently posted an interesting blog post on what he calls the universal design pattern. In there he details using prototypes as a modelling tool, instead of classes. I like the way this introduces less coupling compared to inheritance. But that is something one can get with classes as well, by implementing classes in terms of...
I am trying to call a setTimeout from within a setInterval callback:
function callback()
{
//assign myVar
var myVar = document.getElementById("givenID");
//...
//now wait 2 secs then call some code that uses myVAr
setTimeout("myVar.innerHTML = 'TEST'", 2000);
}
setInterval("callback();", 10000);
setInterval works as ex...
We would need to embed mathematical formulas through AsciiMathML into Google Sites pages (internal wiki for a research team). I am stuck with the limitation of Google Sites.
Any idea how to do that?
(ps: I have finally found a poorly practical work-around, but better ideas would still be appreciated)
...
I am developing some client side javscript that is using some JSON web services on a different domain. I have read that some browsers do not allow cross-domain scripting and that I should create a proxy on my local server to serve the data.
Can someone please point me to a simple example of how to do this in ASP.Net?
...
UPDATE: Thanks to everyone for the responses. I didn't realize document.write() was deprecated. Add a another notch to the learning column. I'll be taking the advice posted here, but leave the original question so that the answers given make sense in context of the original question.
I'm in the process of coding some rather long write...
Hi there,
I'm working on a simple javascript login for a site, and have come up with this:
<form id="loginwindow">
<strong>Login to view!</strong>
<p><strong>User ID:</strong>
<input type="text" name="text2">
</p>
<p><strong>Password:</strong>
<input type="password" name="text1"><br>
<input type="button" value="Check In" name="Sub...
In our application we enable users to print pages. We do this by supplying a button which when click calls the window.print() function.
Some of the pages would look better if they were printed in landscape mode rather than portrait. Is there a way to control the page layout from JavaScript?
Update: Following the advice given here I lo...
David Flanagan's excellent book on JavaScript has an example that shows how to perform XPath queries in IE. On page 518 of fifth edition, you can see the following code snippet taken from example 21-10:
// In IE, the context must be an Element not a document,
// so if the context is a document, use the documentElement instead
if (contex...
I have put together the following mootools script
window.addEvent('domready', function() {
var shouts = "timed.php";
var log = $('log_res');
function updateData (url,target)
{
new Ajax(url,{
method: 'get',
update: $(target),
onComplete: function() {
log.removeClass('ajax-loading');} }).reques...
What is the best method for applying drop shadows? I'm working on a site right now where we have a good deal of them, however, I've been fighting to find the best method to do it. The site is pretty animation heavy so shadows need to work well with this.
I tried a jQuery shadow pulgin. The shadows looked good and were easy to use but...
I have a main window (#1) on my webpage from which I open a new browser window (#2) from which I open a new window (#3).
Now if my user closes window#2 before window#3, I have the problem that window#3 no longer can call function in its window.opener since it has gone away.
What I would like to do is to set window#3.opener to window#1 ...
I'm hitting this error and I'm not really sure why. I have a minified version of excanvas.js and something is breaking in IE, specifically on:
var b=a.createStyleSheet();
I'm not sure why. Does anyone have any insight? I can provide more information, I'm just not sure what information will help.
...
How would I achieve the pseudo-code below in JavaScript? I want to include the date check in the second code excerpt, where txtDate is for the BilledDate.
If ABS(billeddate – getdate) > 31 then yesno “The date you have entered is more than a month from today, Are you sure the date is correct,”.
if (txtDate && txtDate.value == "")
{...
We have a POST to a PL/SQL database procedure that (a) does some database operations based on the POST parameters and (b) redirects the user to a page showing the results.
The problem is, when the user does a browser "refresh" of the results page, that still has the original request, so it calls the database procedure and resends the pa...
What does Mozilla's XPCSafeJSObject wrapper actually do?
MDC's documentation is as follows:
This wrapper was created to address some problems with XPCNativeWrapper. In particular, some extensions want to be able to safely access non-natively-implemented content defined objects (and to access the underlying JavaScript object under an...
Of course, there are a whole range of possible errors relating to document validity, but my immediate stumbling block occurs when changing a paragraph (p) into an address element. My current method is (more-or-less):
var p = $('p#test');
p.replaceWith('<address>' + p.html() + '</address>');
but that fails for this specific case; it wo...