Store Some Custom Property In HTML Element Directly?
Jul 10, 2011I want to store some custom property in HTML element directly, like this:
[Code]...
I want to store some custom property in HTML element directly, like this:
[Code]...
I'm looking for an image cropping tool script that I can provide on my website for users to crop their uploaded photo on my site and I can store them directly on my host. (instead of having to go to another page, or open up photoshop etc, crop their photo, save, and then upload to my site) I see some websites providing this service, does anyone know any scripts that allows me to do this?
View 1 Replies View Relatedi have a script, that adds a custom DOM property to <li> elements (.qqFileId=2 f.i.). Is it possible to select the list item with jQuery by the value of this property? $(...)
View 5 Replies View RelatedI'm having trouble accessing a custom property that I've created for an object. Does anyone see the problem with this code? this.imageSrcs is undefined inside of getImages.
Quote:
Gallery.prototype.imageSrcs = new Array();
Gallery.prototype.getImages = function(json) {
if (json) {
[code]...
suppose I have the following:
Code HTML4Strict:
<li id="lists">
<a> ... </a>
<li>
[code]....
here it now selects all a tag in "lists" but I only want it to reference the a tag that is the direct child of "lists" li. I want it to ignore the freen highlighted part.
<li id="lists"><a> ... </a><li><a> ... </a>
<a> ... </a>
<a> ... </a></li>
</li>
Suppose I have a page that I cannot edit(in before "get a real host") but can apply Javascript to. For stylistic purposes, I would like to wrap the contents of the page in a <div> or <table>. Could I use Javascript to insert the needed HTML tags directly after the <body> tag in a fashion similar to document.write? I'm not very familiar with Javascript, but I've tried a few half-baked solutions of my own using GetElementsByTagName('body') and other variants, but no luck. I've tried scanning Google as well but I couldn't find anything that would work for me there either but I'm not sure if that's because I wasn't searching for the right keywords or what.
View 2 Replies View Relatedi have got about 50 definition lists on one html-page witch all look linke this:
<dl>
<dt class="title">aaa</dt>
<dd class="subtitle">bbb</dd>
<dd class="city">ccc</dd>
<dd class="email">ddd</dd>
<dd class="website">eee</dd>
<dd class="description">fff</dd>
</dl>
if the dt-element in one of the definition lists has a specific css-property (e.g. length > 100px) then the dd-element with the css-class "subtitle" in the same definition list should be removed.
I'm doing a very simple expand/collapse function using 'slideToggle'. The button that triggers this event simply says 'Expand/collapse'. I want this text to change depending on whether an element is visible or hidden.
[Code]...
I have an object with a single Method to load content from a xml file. The problem is... how do I add a property to the object to store the data loaded?? I tryed adding a simple Array inside the object, but didn't work.
[Code]...
Is there a way in JS to store an object in an element?
View 6 Replies View RelatedI am working on a e-commerce site and I need to hide the checkout link (<a>) if the value of of the element (<td>) holding the amount due ="$0.00".
<tr
>
<td
colspan
[code]....
I've gone back and forth on the best way to store data in HTML elements which is used to support JavaScript. For instance, I might have a bunch of rows each associated with a SQL ID, and upon clicking the delete element, want to grab the id, and send it to the server. I've successfully used the following three solutions, but would like to standardize on just the best.
Option 1 is technically valid, but seems excessive. Option 2 will work fine, but is considered by some as bad practice. Option 3 requires the extra step of splitting the ID from some identifier string, and care not to have the same record twice on the page.
HTML Code:
I'm using this bit of jQ to add a class to two different elements based on the class of another (parent/grandparent, etc) element.
First, when there's no class at all in <div id="main-content">, the 'active' class is added to *all* the #nav-primary LIs, and also to *all* the #aux-left DIVs; how can I modify this so that in the absence of any class on #main-content, do nothing?
Second, how can I target only the first or second of multiple classes to store in the 'containerClass' variable, e.g., <div id="main-content" class="apples bananas">?
I want to store the main content of my site (with it's HTML) in an XML file such as:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<data>
<h3>Hello World</h3>
<p>Here is some content, blah...</p>
<p>Yet another paragraph</p>
</data>
<data>
<h3>Section 2</h3>
<p>More stuff to read</p>
</data>
</root>
And I want to load all the HTML in a data node via an onclick event. I've got the following basic AJAX code:
<script type="text/javascript">
<!--
function ajaxRead(file,node) {
var xmlObj = null;
if(window.XMLHttpRequest) {
xmlObj = new XMLHttpRequest();
} else if (window.ActiveXObject) {
xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
} else {
return;
}
xmlObj. {
if(xmlObj.readyState == 4) {
var parentNode;
parentNode = xmlObj.responseXML.getElementsByTagName('data')[node]
updateObj('xmlObj', parentNode.firstChild.data);
}}
xmlObj.open ('GET', file, true);
xmlObj.send ('');
}
function updateObj(obj, data) {
document.getElementById(obj).innerHTML = data;
}
//-->
</script>
If I remove the HTML tags within the data node it works, but obviously there is no formatting, and its just all text. How can I load the HTML content into the div? Note: 'xmlObj' is the name of the div I'm trying to populate.
I want to store the sourcepage of a html page in a variable; how can I do this? this page is not the one who contains the script, the page is delivered by a textbox
View 4 Replies View RelatedI'm currently trying to create a script which can grab the HTML from a web page and store it. For example, if I want to use google and search for the term "dogs", I want to be able to access that information.
How can I implement this in JavaScript, if at all?
I have written the code below. What it is supposed to do, is grab the HTML from a .NET panel (div) and make the changes and store them in a textbox, so that when the page is posted, the values are retained and can be re-read back to the .NET panel. I have found this script works in IE but doesn't work in FF. Now I know it is something I am doing wrong, but I can not work out what it is.
Code:
I have checked my syntax and I am sure it is correct. The only thing I can see that might be causing the problem is that I set final as the original and then I get the list of inputs.
From there I loop through and set the value of the inputs to the new values.
If I do an alert, the value shows what I would expect, but setting the store value as the final innerHTML doesn't appear to keep these values.
Could it be that once I pull the inputs from the final (placeholder = final.getElementsByTagName("input");) then changes I make to them do not affect the final variable?
Can I target the element and base an onChange outside of directly calling it in the element tag?
Due to the nature of my script, the best I can do is wrap a tag around the element.
example of what I am trying to do
Code:
<script>
document.form.field1.onchange = function();
<script>
And if this might work, can I call it in the head or must it come after the element.
How would I get an element's display property? For example, I can get the width by using the_element.offsetWidth, but what do I use for display?
I tried the_element.style.display, but it doesn't seem to work.
I have a custom HTML tag: <custom>text is here</custom>
I can do anything I would like in terms of calling methods with mozilla
but not IE 6. For instance calling appendChild in IE results in an
error. The innerHTML property is blank even though there is text
between the tag.
Is there a work around for IE. What gives with IE and being able to
access and manipulate custom tags??
I know very little js, but I've been reading up on it, mainly for one reason. (I'm a PHP programmer and I've just used js for small tasks like client-side form validation, that sort of thing).
What I want to do is make a textarea with buttons, similar to a BB editor, but which will use defined html tags; I'll use <div style="box1"> and <h1 style="greenunderline"> for examples. I've tried to modify some open source editors and get utterly lost in trying, and I'm not sure that approach would work anyway.
The buttons would need to function two ways, again like a BB editor.
1) It could simply insert the start and end tags in the textarea;
2) If text were selected, it would put the tag in front of the selection and the end tag after.
If I can get this done, I think I can handle a preview function. I haven't even gotten close to getting javascript to "get" selected text inside a textarea.
When introducing custom functionality to HTML elements we either use existing attributes to pass configuration parameters (like beetle's fValidate (http://www.peterbailey.net/fValidate/)) or invent our own (like my Tooltips (http://www.vladdy.net/webdesign/ToolTips.html)). While this method is ok for small amount of configuration information, it is not that flexible (you need to edit DTD) and becomes combersome when large amount of configuration parameters is needed.
I figured a more convinient way is to use a CSS like string to pass configuration parameters:
<div myextension="parameter1: value1; parameter2-subparameter1: value2.1; parameter2-subparameter2: value2.2"> </div>
Then initialization routine would contain:
if(myExtensionParameters = divElement.getAttribute('myExtension'))
divElement.myExtension = new myExtensionObject(divElement,myExtensionParameters);
Definition of possible parameters and their values can be done using an array of regular expressions:
myExtensionParamDefenitions = new Array();
myExtensionParamDefenitions['choiceparameter'] = /^s*(value1a|value1b|value1c)s*$/;
myExtensionParamDefenitions['stringparameter'] = /^s*(w+)s*$/;
myExtensionParamDefenitions['integerparameter'] = /^s*(d+)s*$/;
Constructor for the myExtensionObject would containd a parseParameters function:
function myExtensionObject(divElement,myExtensionParameters)
{ this.params=new Array();
parseParameters(this.params,myExtensionParamDefenitions,myExtensionParameters);
//Verify parameter initialization, if you like
str=''
for(e in this.params) str+= e + ': ' + this.params[e] + '
'
alert(str);
//Do whatever you have to do...
}
Function parseParameters has the following code:
function parseParameters(object,definitions,parameters)
{ paramEntries = parameters.split('');
for(var i=0; i<paramEntries.length; i++)
{ paramEntry = paramEntries[i].split(':');
if(paramEntry.length == 2)
{ paramName = paramEntry[0].replace(/^s*([w-]+)s*$/,'$1');
if(definitions[paramName])
{ res = definitions[paramName].exec(paramEntry[1]);
if(res[1])
object[convertCSSName(paramName)] = res[1];
}
}
}
}
Where convertCSSName function converts CSS type name (background-image) to javascript name (backgroundImage)
function convertCSSName(cssName)
{ sn = cssName.split('-');
rs = sn[0];
for(var i=1; i<sn.length; i++)
rs += sn[i].replace(/^(w)(w*)$/,function(str,p1,p2,offset,s){return p1.toUpperCase() + p2;})
return rs;
}
As a result you have params array of myExtensionObject object populated with validated entries. Changes and expansion is done by simply editing myExtensionParamDefenitions array.
PS: The functions are coded more for clarity rather than for brevity - I'm certain there are ways to improve the implementation.
I'm trying to run a function that reads the css property of an element and copies it over to another element on click.
I'm sure a huge part of my problem is that I'm stillstrugglingto learn the correct syntax for things, but I'm sure it's framed like this:
I didn't want to post my ACTUAL attempt to code this, mostly out of shame. But I'm pretty certain that it's ridiculously incorrect.
I would like to be able to test if an element already has a style applied to it. This style might either be an inline style, or come from a stylesheet. I'm writing a plugin which needs to apply a CSS style to an element if it's not already there.
View 1 Replies View RelatedI've been having this issue with Javascript that is just not getting resolved for a while. What I am basically doing is building a simple web browser extension that injects javascript on certain pages. I am using Firefox, Chrome and Safari. The issue I am having is accessing these so called "special properties" on a particular page. They look like the regular classNames, id, textContent and such but don't appear to be standard. It would be very helpful if I can access them.
A particular example would be in Yahoo Mail. When you are in your inbox you have list of messages. With each message row there are associated attributes. You can get to them with your web inspector or if you search for the div element with id "PagedTableView_wrapper", then follow the first child and then second child and you get a list of these messages being rendered. Each one of those rows has the regular className properties and such but also has "_checked", "_focused", "_selected" that look like custom Yahoo ones. I basically want to read those.
The issue is I can't. I always end up getting a null exception, as if it doesn't exist. I can read the className and the other standard ones fine, but not the special ones. (I've verified its the same element as well). I have tried the DOM navigation route with indexing, jQuery and XPATH, all with the same result. The weird part is that I can see them with the webInspector! Whats even more strange is that if I run firebug or commands in the Console, it actually works! But it doesn't work for my injected code/extension! Baffled.
how to change the css display property of a table, from hidden, to block outside of an iframe.
//This data is outside of the iframe
<style>
#table {display: hidden; z-index: 100;}
</style>
[Code]....