Alternatives To Built-in Objects As Prototypes
Jul 21, 2006
I have been looking at Prototype.js quite a bit lately as I need to
create a very small library of similar functionality to a subset of
Prototype.js. This is for use with Ruby on Rails.
About Prototype.js Rob G wrote:
1. It modifies the protoype of some built-in objects so that
using say, for..in with an array object produces unexpected
results.
I can see that modifying the prototypes of Object or Array could break
other JavaScript libraries that depend on for..in. Prototype.js also
adds functions to the prototype of Element. How bad is that? (I notice
that in Flanagan's JavaScript 4th edition he mentions that you can
modify the prototypes of built in objects however there is no mention
of the dangers involved.)
I then thought I could use an instance of Element as the prototype of a
MyElement constructor but that option has been squashed in the past as
being not cross browser.
Assuming I shouldn't be playing with the prototypes of built-in
JavaScript objects I can see a couple options that might still be
available. Code:
View 1 Replies
ADVERTISEMENT
Jul 20, 2005
I'm trying to inherit from built-in JS objects - Array, specifically.
However, I'm having some difficulties. I can add array elements to
the child object, and when I retrieve them, they're the same as what I
added. The problem is, the 'length' property remains zero no matter
how many elements the child contains: Code:
View 3 Replies
View Related
Aug 4, 2006
Have you ever wondered what functions were included in javascript? Have you ever wondered what properties and methods each javascript object supported? You can use this script to display a complete list of all javascript objects supported by your browser. The type of the object will appear in bold. As long as the type is not listed as 'undefined' you can click on that object to view all the supported methods and properties. The back and forward buttons will not work with this script due to security precautions that are built into Firefox. However, I have provided links at the top of each page to help you navigate back and forward between pages.
Usage:
Download the attachment to this post and extract the getObjects.js file. Then add the following code to your webpage.
<script type="text/javascript" src="getObjects.js"></script>
//call the function by using the following link
<a href="javascript:getObjects('window');">Show Objects</a>
//you can substitute the window object with any object of your choice
<a href="javascript:getObjects('window.Components.interfaces');">Show Objects</a>
View 1 Replies
View Related
Mar 26, 2011
Link me to a good guide or tutorial for prototypes?
View 6 Replies
View Related
Jan 1, 2011
In the spirit of the season, I wanted to make it snow on my website. So I began digging. Eventually I ended up with a script that moved an image element down the page in a snowflake-like manner. The problem with it was it was dependant on an img element for every flake - simply no poor programming when using an Object Oriented programming language.So I decided I wanted to extend (in Java-speak; most of my programming background is in Java) the in-built Image object. The new object's src variable will lead to an image of the type of flake it is. (I want to be able to have more variance in images than a simple dot.) The new object will have a function that will allow it to move.A separate,unrelated function will control when each flakes move.
I did some more research and read about prototyping on JavaScript Kit and here (http://mckoss.com/jscript/object.htm), but I still cant seem to get this to work. JS Lint says it's bug-free, but Firefox says "move()" is an invalid function. I am presuming the problem lies in my inability to fully grasp how to extend objects in JavaScript.
<html>
<head>
<script type="text/javascript">[code].....
View 6 Replies
View Related
Oct 19, 2006
I'm currently using overLib 4.21 which works well for the most part, but it
doesn't fully support CSS and doesn't always behave properly with Safari
(for the Mac.) It's also overly bloated for my needs.
I simply want a popup div to display a form. The user either inputs some
data and submit or ckicks cancel to close. Code:
View 3 Replies
View Related
Feb 27, 2006
Are there any ways to edit the html within an element without knowing the TagName?
I'm trying to add html code within a <td> element that has no name or ID. What I do know is that it's the third <td> element within the only <tr> in the table. Assume that none of the elements in the file have IDs or names. The html is produced by a compiled program, so I have no way of editing the HTML in order to add names or IDs. Code:
View 5 Replies
View Related
Jul 26, 2006
I have dynamically named form elements set in divs based on a
server-side language. I am displaying these using DHTML in a
display:none, display:block format.
Due to some code (and deadline) issues I do not have the total number
of form elements set by the time the body tag is run. I wanted to have
a script tag later on in the document which reads something like:
<query>
<builds div element1i1, element1i2, etc>
<script language="javascript">
document.getElementById(' query variable '+1).style.display = 'block'
</script>
</query>
However the JavaScript code does not run. Alerts run inside the code
consistently, but the other code does change the display to block.
also tried running this same code as on OnFocus...
View 3 Replies
View Related
Mar 29, 2011
I wrote a website in html, which has an ecommerce that sends the purchase to paypal. My client wants to offer a coupon. I found code in javascript that validates the coupon, but I want to be able to tell PayPal the discounted amount as this discount will not apply to all customers. PayPal Merchant Services told me that I can not use a variable in the following line:
<input name="amount" type="hidden" value="132" />
Is there a way I can use Javascript to do the following? At this time, this code doesn't give me an error, but it doesn't send the amount to PayPal either.
<script language="javascript">function validate(text1,text2) {
if (text1 == text2)
{ document.write('<input name="amount" type="hidden" value="0" />')
[code]....
View 8 Replies
View Related
Jul 28, 2010
Is there any alternative way to disable elements in real time as .attr("disabled",true) or .attr("disabled","disabled") do not work in IE7, only with IE8 or FireFox 3?
View 4 Replies
View Related
Apr 17, 2011
Is there a way in Javascript or Jquery to return an array of all objects underneath a certain point, ie. the mouse position. Basically, I have a series of images which link to various web pages but I have a large semi transparent image positioned over the top of the other images. I want to find the href of the background image that the mouse pointer clicks over.
View 1 Replies
View Related
Oct 8, 2009
I decided when redesigning my website that i would try and build nearly everything in it by hand, which included a nice Javascript slideshow.While coding it (coded on Windows 7 and Vista) I ensured i checked it compatability with Firefox, IE, Chrome and Safari. From what i could tell everything was working good (except for some endless looping problems but lets ignore that for now). It even worked on the iPhone browser.
But i sent it to a friend to test and they said nothing was working, after some discussion i descovered they were using IE7 (i was testing in IE8).From what i can see, IE7 has some problems with nested .appendChild and general document handling. I had tried to do my best keeping to using objects in javascript and now just writing HTML, and on one side it worked as it works on most browsers, but not IE7.
The code is nearly all based in a class, but i kept finding problems so there are a few functions found outside the class.The area where most things go wrong is in the function:
this.goToImage = function (image) {
As this is used to generate the floating div above all the content. This function also uses IMG objects which are hidden until the image has loaded (instead showing a nice please wait logo) and then once loaded it appears. I have tried using .innerHTML to get around the append child problems but the images dont seem to work the same as just passing object around.
View 2 Replies
View Related
Oct 19, 2011
I am building iframes from database entries. Is it possible to resize them with an onclick event?
View 1 Replies
View Related
Jul 30, 2009
I am trying to add a link to an existing nav menu built in javascript. I need this link to open in a new window, but I cannot get it to work
View 4 Replies
View Related
Oct 7, 2011
I am using prototypes (library) ajax methods and one of them is properties. I am passing in the name value pairs:
var itemFilter = "MajorCat: Shoes",
parameters: { q : qry ,fq: itemFilter },
But when I request, it gives me this in the url: MajorCat%3AShoes That won't work, the search application on the backend doesn't filter properly because of the "%3A" instead of ":". When I manually pass in via the url: MajorCat: Shoes (at the end of the query) it works. So, that ":" is getting encoded. How do I get that IN the hash and make sure the request is unencoded when it goes out?
View 3 Replies
View Related
Nov 6, 2007
I'm building the "Contact Us" section of my .mobi site (xhtml and
html).Is there any way to create an e-mail form that use the mini-browser
built-in mailer? (Perhaps a javascript code to add ?)
View 2 Replies
View Related
Nov 21, 2003
To build a horizontal floating menu that matches the first row (header row) of my dynamically built table (to include text and cell height/width - needs to match exactly). I have accomplished 90% of this task by extracting the text and building the row in my floating menu header and placing the floating menu where it needs to be. However, I'm having a problem aligning the table (<TD></TD>) cells because of my dynamically built table.
Scenario:
I have a table that is built dynamically. Before it is displayed, I format the table row data (code that adds text/deletes rows etc…), which alters the width of all the table cells (via JavaScript). We'll call this (for lack of a better phrase) "pre_floater_table_format_code."
I then loop through the DOM (<TD></TD>) in the first row of the table to get the text and width from each cell (using offsetWidth and/or clientWidth) and assign the text and cell width(s) to variables that I use to build my floating menu with. We'll call this (for lack of a better phrase) "get_cell_text_width_code."
Problem:
The problem is that once the table is built (and before it is altered by the "pre_floater_table_format_code") it seems as though my "get_cell_text_width_code" reads the un-processed table cell width(s) and sets these variables to the un-processed width values. The "pre_floater_table_format_code" runs much earlier than the "get_cell_text_width_code." So why wouldn't the "get_cell_text_width_code" read the cell width(s) after they've been adjusted by the "pre_floater_table_format_code?" Does this make sense? Anyone have any recommendations? Alternative solutions?
View 2 Replies
View Related
Aug 20, 2005
i'm trying to do is have a textbox which some types 'hello world' into (or whatever), a script that takes that input and splits it into an array of individual letters, finds the appropriate graphic version of each letter and spits it out on the screen. so far i have Code:
View 1 Replies
View Related
Sep 5, 2009
Is there a better way to extend object with internal objects?
$.fn.bestShow = function(s) {
var d = {
width: 0,
height: 0,
order: "numeric",
orderBy: "",
[Code]...
View 3 Replies
View Related
Sep 13, 2009
I am having difficulty with the isNaN built-in function. Here is the code that I have written, with the event handler onchange, the function does not return the desired response.
CODE:
Here is an example of the event handler code...one of three calls to this specific function...
<input type="text" name="zip_billing" size="5" maxlength="5" onchange=" return checkNumber(this.value);" />
View 1 Replies
View Related
Apr 24, 2006
I need to attach a javascript function I wrote to the onChange event of
a <select> tag. However, I'm using a 3rd party tool that creates the
html files - it only lets me add bits of html to it, I can't touch the
elements it produces, so I can't just add an onChange="myfunction"
attribute to that <select> tag. I can't change the onload attribute of
the <body> tag.
How can I run code that attached my function to that event?
View 3 Replies
View Related
Jul 30, 2011
I have built search form that it retrieves information from database. for ex: when i click axtar (search) button it retrieves normally but when i click ENTER button via keyboard instead of axtar (search) button but it only displays results with white blank page
Here is web page address. [url]
View 5 Replies
View Related
Dec 23, 2010
is there any alternatives? My hosting is a Shared hosting so I guess somehow its limited...
View 4 Replies
View Related
Mar 10, 2010
I'm using jquery/ajax to create some links with window.open method. Here's the relevant code:
$("#content").empty();
$.ajax({
type: "GET",[code]..........
Basically, when you click a link a function is called with a parameter based on the particular link you run. Then the code runs through an xml file, and if the parent of the nodes I've cyling through has a value equal to the parameter past to the function, that node is used to create a new link with window.open function attached to it.It all works, or seems to, and when I alert what is being built, it looks right to me, yet the links don't work.I've attached a copy of one of the alerts of one of the links as it's built.
View 5 Replies
View Related
Jul 1, 2009
Can assign a new function to a built-in object in Firefox:
But IE and Opera don't have a MouseEvent or HTMLElement that can be set up in the same way. Can you do this in IE or Opera, or just Firefox, and maybe Webkit?
View 1 Replies
View Related
Oct 6, 2011
Is there any way at all to create a new template object that inherits from the built in Date object so as to be able to add new methods to that child object without adding them to the built in Date object? I've tried everything I can think of and as far as I can tell it keeps referencing the Date function instead of the Date object and so doesn't work.
View 3 Replies
View Related