I am developing some JavaScript that should work with either Prototype.js or JQuery, thus I need some way to identify what is the primary library in use. How can I do that?
I'm working with an existing JavaScript-powered cart module that I am trying to modify. I do not know JS and for various reasons need to work with what is already in place.
The text that appears for my quantity box is defined within an existing function:
function writeitems() {
var i;
for (i=0; i<items.length; i++) {
var item=items[i];
var placeholder=document.getElementById("itembuttons" + i);
var s="<p>";
// options, if any
if (item.options) {
s=s+"<select id='options"+i+"'>";
var j;
for (j=0; j<item.options.length; j++) {
s=s+"<option value='"+item.options[j].name+"'>"+item.options[j].name+"</option>";
}
s=s+"</select> ";
}
// add to cart
s=s+method+"Quantity: <input id='quantity"+i+"' value='1' size='3'/> ";
s=s+"<input type='submit' value='Add to Cart' onclick='addtocart("+i+"); return false;'/></p>";
}
placeholder.innerHTML=s;
}
refreshcart(false);
}
I have two different types of quantity input boxes; one (donations) needs to be prefaced with a dollar sign, and one (items) should be blank.
I've taken the existing additem function, copied it, and renamed it so that there are two identical functions, one for items and one for donations. The additem function is below:
function additem(name,cost,quantityincrement) {
if (!quantityincrement) quantityincrement=1;
var index=items.length;
items[index]=new Object;
items[index].name=name;
items[index].cost=cost;
items[index].quantityincrement=quantityincrement;
document.write("<span id='itembuttons" + index + "'></span>");
return index;
}
Is there a way to declare a global variable based on which function (additem or adddonation) is called so that I can add that into the writeitems function so display or hide the dollar sign as needed? Or is there a better solution?
I can't use HTML in the body of the cart page because of the way it is currently coded, so I'm depending on the JS to take care of it.
Any help for a newbie is welcome. Thanks!
Hey
I'd like to know how to use XMLHttpRequest to load the content of a remote URL and have the HTML of the accessed site stored in a JS variable.
Say, if I wanted to load and alert() the HTML of http://foo.com/bar.php, how would I do that?
Thanks!
Hi all,
I have to make some charts on a "mobile" website, what is the best framework to do this?
I see Google Charts API, JQuery Visualize, Raphael and JS Charts... but i don't know who is the best one in Safari Mobile.
Thanks in advance to your response.
I'm creating a script with javascript which works in every browser except IE.
<script type="text/javascript">
(function() {
var sc = document.createElement('script');
sc.type = 'text/javascript';
sc.src = 'http://domain.com/script.js';
(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(sc);
})();
</script>
How could I get this working in IE (tested IE6, IE7, IE8)?
hi guys.
How do I disable the save password prompt in web browsers whenever I'm submitting a form. I've seen a few bank sites where this doesn't come up.
Are they doing it through JS or there any http headers or HTML meta tags available to achieve this?
I'm trying to do this for a mobile application. Please pour your ideas.
http://plugins.jquery.com/project/semantictabs
What is the means of this
Status - Recommended for 1.0.x
I'm using this plugin code as it is http://plugins.jquery.com/files/jquery.semantictabs.js_4.txt
then this ( I'm also using prototype.js onsite)
jQuery.noConflict();
jQuery(document).ready(function(){
$("#mytabset").semantictabs({
panel:'.mypanelclass', //-- Selector of individual panel body
head:'headelement', //-- Selector of element containing panel header, i.e. h3
active:':first' //-- Which panel to activate by default
});
});
Hi,
In Rails is there a way to get the URL to the image (going through the assets_host) and just return the URL of the image? I want to use assets_host data in my Javascript, but I just need to insert the URL into the JS, not the whole image_tag.
Thank you in advance!
I have a flash app (SWF) running Flash 8 embedded in an HTML page. How do I get flash to reload the parent HTML page it is embedded in? I've tried using ExternalInterface to call a JS function to reload the page but that doesn't seem to work...
Hello
While trying to understand how a web server worked, I came accross this:
//myfile.js
function donothing(){};
//myfile.html
javascript:donothing(open('http://www.acme.com/whatever.jpg','','left=100, right=0, top=100, scrollbars=no, status=no, titlebar=no, resizable=no, toolbar=no, menubar=no, width=255, height=255'))
I'm no JavaScript expert, so I don't get how an empty function can be made to work. Does someone know?
Thank you.
I'd like to measure to distinct user experience points during the rendering of an HTML page:
1) Point which user sees the first painting of the page
2) Point at which user can interact with the page - meaning sees 75% of it or can actually register a button click or link click
I am pretty certain these UX interactions can start before the HTML code is fully rendered, so would that instance be the JS func "OnLoad" or some other distinct measureable value/function?
If it helps, we can even narrow the answer down to webkit based browsers.
As no one can help me with my UJS ajax problem I am trying "respond_with", but I am getting this error:
RuntimeError (In order to use respond_with, first you need to declare the formats your controller responds to in the class level)
Yet I have declared it in my controller:
class HomepagesController < ApplicationController
respond_to :html, :xml, :js
def index
@homepages = Homepage.search(params[:search])
respond_with(@homepages)
end
Anyone has any ideas why.
I have a OpenVZ VPS running CentOS 6.3 64 bit and when I try to install JRE 7 64bit using the command:
rpm -Uvh java.rpm
It gives me this error:
Preparing... ########################################### [100%]
1:jre ########################################### [100%]
Unpacking JAR files...
rt.jar...
Error: Could not open input file: /usr/java/jre1.7.0_09/lib/rt.pack
jsse.jar...
Error: Could not open input file: /usr/java/jre1.7.0_09/lib/jsse.pack
charsets.jar...
Error: Could not open input file: /usr/java/jre1.7.0_09/lib/charsets.pack
localedata.jar...
Error: Could not open input file: /usr/java/jre1.7.0_09/lib/ext/localedata.pack
I then tried the command:
java -version
And it gives me this error:
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine
Error: A fatal exception has occurred. Program will exit.
Why does this happen if I have more than enough RAM on the VPS to run this (1GB)? Could it be an issue with the host node of the VPS?
Thanks
EDIT 1: Link to beancounter screenshot http://puu.sh/1xwxB
EDIT 2: Link to htop screenshot http://puu.sh/1xwDl
This overlay seems to be the only overlay plugin that works within my schools wonky template... but the problem is that when the browser is resized the shadowbox resizes too, clipping the contents inside. I want it so the box stats fixed and if the browser does get smaller the browser will have scrollbars.
I know it's been modified before, but i dont know where to start. I cant even find an unminified version of the .js file.
Thanks
Is there a way to get the timezone of the connecting user using Pylons, and to adjust the content before rendering accordingly? Or can this only be done by JS?
Thanks.
I have some hover() JS code:
$( '.leftMenuProductWrapper').hover (
function () {
},
function () {
});
In the second function, I need something like:
If ($("#leftMenuWrapper2").hasMouseover){
do this
}else{
do that};
I can't find any documentation on how to do it.
Can someone who is a master at JS tell me what's wrong with this?
if ( $.trim($("#add-box-text").val()).length < 2 && $.trim($("#add-box-text").val()) != "Click here to add an item" ) {
// If it's LT than 1 Character, don't submit
$("#add-box-text").effect('highlight', {color: '#BDC1C7'}, 500);
// Refocus
$("#add-box-text").focus();
}
hi,
I'm loading from my main page an external js file, with a function.
I have a flash file in the main page invoking the javascript function.
Everything worked very well until when the javascript code was in the main file, but when I moved javascript to an external file the function seems not called anymore.
So... there is no way to move the javascript code to an external file ? Or any other solution ?
thanks
How to easily change the format of URL in a right way:
/comment/10.js?param1=6
to
/comment/10?param1=6
Preferrably with some URL library or so, not with regexps.
I'm using the jQuery Validation JS
I have two contact forms, the main one that appears on one page only, and a quick-contact that is on all pages.
How can I prevent quick-contact form to show the error messages ONLY on submit (without effecting the other form)
Can you create reusable components in html? Let's say I want to encapsulate some css / html and js into a tidy reusable component. How do web developers do this? I'm coming from the Flex, C# side of the planet.
Hi,
The standard extension for template files in Zend Framework is .phtml... I need to change them to .js in one specific module... can anyone help... I'd ideally like to change this a Controller level...
Many thanks...
i wonder if ruby on rails have bundles, the ones similar in django?
kind of a plugin that contains css, js, images, ruby code and everything for one feature.
thanks