I would like to include extra "hidden" information in a generated HTML page
that can be used by javascript functions.
I realise that most browsers seem to ignore any tags and attributes they
don't understand, but from what I can tell the standards do not allow me to
make up my own tags or attributes as they will fail validation.
is there any standard element name that can be used for such a purpose i.e.
passes validation but never produces any output (and ideally allows nested
elements to be rendered normally too)...
Here's what I'm trying to do: 1) I get reference to a div that's on my page: var theDiv = $("#" + divID); 2) Now I want to add a custom attribute tag to it, so for instance I want to add "winWidth" so that the div object now contains "winWidth=" for instance. 3) I want to set winWidth now since it's part of theDiv to a value
I'm not sure how to really do 1 + 2. I need to do this on the fly because some javascript logic later will add these attributes dynamically to the div... outside of what the original div had...I don't care what it had, I know I have it now in a JS variable and now I want to both add some new attributes to the div, and then set them on the fly. I don't need these attributes to be on my page, I just need them added to my div variable reference.
Does anyone know of a way to wrap custom tags around selected text using execCommand or otherwise?
I am developing a rich text editor for use in a web site and while there are a few decent ones already floating around I need to implement a few extra bits of functionality. Specifically tool tips. Idealy I'd like to wrap custom tags around selected text using execCommand. Ie "Selected Text" becomes:
I need to replace custom tags to spans. I have: Code: <block style="color:blue" class="block01" limit="100">This is a block</block> I need to fetch the attributes and add them to a span, like: Code: <span style="color:blue" class="block01" limit="100">This is a block</span> There's a few on the page so I need to change all of them some may have many attributes.
I am trying to find how to use custom tags in html and render data based on their use.
A good example is the joomla <jm:whatever> tag.
I found the following article: [url]
I think it might be outdated though because the behavior:url element does not seem to work. Plus, when I check the style sheet on a joomla site, it doesnt seem to use this method. I think these tags might be xml but I do not know how to render them based on the tag.
For example: <customAbbrv:display src="test.html" label="Test" />
I would want this tag to fire test.html and pass the attribute label which is set to Test.
I am trying to wrap <a> tags around text in <li> elements. How can I get the index of the <li> in the <ul>? I tried something like this: $('.tabbed-list li').wrapInner('<a></a>'); That works fine. However, I want to do something like this: $(this).wrapInner('<a href="#' + $(this).index() + '"></a>');
I've been programming in jQuery for some time now, and for the first time, I came across an issue where I am writing out the location of a TD with an ID="step" to get the innerHTML with html(). I receive a null value, but when I use td:first within the chain of elements, it works.Has anyone experienced this issue or have any idea why this is not working? I've tried other TDs with diffirent IDs within the same row, and the same null result happens.Is there a possible limitation to the numbe of IDs used within the chaining of the $() call?
I have now been playing around for hours trying to figure this out. Swore I would not ask for a solution. Now I have a headache, so I am asking. On one HTML Page (From.htm) I have:
[Code]...
I somehow, need to get the values as shown in the handle function for each of Products shown in From.htm. Keep in mind the only thing I know from From.htm is the class names. I have no idea what products are listed or what the input names are. This table is generated by a third party. Assume that index.htm and From.htm are on the same website.
Can't seem to make it work, I have seen many examples but they are all just for 1 div tag. When i trymore than one it doesn't work anymore.The first one works, if i have more than 1 then the other don't work.
using the following jquery $(document).ready(function(){ $("#toggle-text").click(function () { var divvalue= this.value;
Is it possible to trigger the action of a form with a submit button that's outside the form tags? If so, how should this example be rescripted to make the input tag work outside the form tags?
I really know nothing about how to code JavaScript (I know what it is and what it does) and I need a script to go in the head of my page and look for all <a> tags that have <img> tags inside of them and add a rel="lightbox" attribute to them.
I have a page I am working and I am having some trouble with: I need to show and hide areas based on a radio selection. I initally started using the show / hide feature in Jquery but the problem is the elements need to be removed but then put back if the user selects the radio buttonagain as it has form elements that have validaion on them. The validation is still trying to validate the form elements becuase they are still on the page but just not showing. This is the radio group the user makes the selection from:
I have HTML tags stored in XML. I want to be able to use these HTML elements with Javascript, just as you can with elements in document.body. How can it be done? (And don't try and tell me I should use server-side because I have written it all for Javascript and the project is nearly complete minus this and there are practical reasons for not doing this server-side. After all, anything is possible with Javascript!)
Let me explain:
- I have HTML templates such as this [URL]
- I want javascript to populate these templates then add them to my page
- The only way I know javascript can get this kind of data is by parsing XML
- I want to parse the XML then be able to use the HTML elements just like those in document.body
- As far as I'm aware, XML is the only good way of storing data for javascript. I don't want to store it in javascript variables (too much multiline data with " and '). Nor do I want to build it using document.createElement("div")... etc
As someone not yet with any experience in computer science etc, please ignore my poor terminology! However, I'm not a beginner when it comes to javascript.
Here's the script concerned but I doubt it'll help you understand my problem: [URL]
So i've got a form that adds an element onto the page. This is working. When I try to remove said elements, that works. But the same 'delete' button doesn't work on elements not generated by javascript.
Code JavaScript: function destroyQuickTask() { $.post($(this).attr("href"), null, null, "script");
function unHide (fieldname) { .... not important... document.form1.fieldname.style.visibility = 'visible'
}
I have a field name called country in a form. When the onclick="unHide('country')" is used then the above function does not work but if i change the following line within the function document.form1.country.style.visibility = 'visible' then it works.
I've tested it in most recent versions of IE, FF, Opera, and Safari.
The first parameter is the alert's text, if a second parameter is passed, it is the alert's title, else it will just have "Alert" in the title.
You can fire the function as many times as you like, any alert's thrown after the first will set themselves on top of each other slightly staggered much like the built in alert.
The alert will automatically be placed in a visible place regardless of where the page has scrolled. They will also stay in that same place in relation to the screen if the user scrolls after the alert has fired.
The top most alert is the only one clickable and moveable until it has been acknowledged (Much like a regular alert).
The benefit of this is that it does not freeze the user's interface once the alert is thrown.
Here's the code:
Javascript:
//***************************** // Custom Alert Box // Free to use with credits in tact. // Written By Adam Matthews aka Basscyst //AdamDMatthews@Gmail.com //***************************** function msgBox(msg,hdr){ if(!document.getElementById('alerts')){ var div=document.createElement('div'); div.setAttribute('id','alerts'); document.body.appendChild(div); } var div=document.createElement('div'); div.className="alertbox"; var h3=document.createElement('h3'); h3.className="alerttitle"; var p=document.createElement('p'); p.className="alerttxt"; var footdiv=document.createElement('p'); footdiv.className="alertfoot"; div.appendChild(h3); div.appendChild(p); div.appendChild(footdiv); var but=document.createElement('input'); but.setAttribute('type','button'); but.className='alertbut' but.setAttribute('value','OK'); footdiv.appendChild(but); var hdr=(hdr) ? hdr : "Alert!"; h3.appendChild(document.createTextNode(hdr)); var cut=msg.split(" "); var len=cut.length; p.appendChild(document.createTextNode(cut[0])); for(var i=1;i<len;i++){ p.appendChild(document.createElement('br')); p.appendChild(document.createTextNode(cut[i])); } document.getElementById('alerts').appendChild(div); window.onscroll=function(){ placeAlerts(); } window.onresize=function(){ placeAlerts(); } placeAlerts(); } var posX; var posY; function mouseXY(e){ if (!e){ var e = window.event; } if (e.clientX) { posX = e.clientX + document.documentElement.scrollLeft; posY = e.clientY + document.documentElement.scrollTop; } else { posX = Math.max(e.pageX,0); posY = Math.max(e.pageY,0); } var coord=new Array(); return coord; } if(document.captureEvents){ document.captureEvents(Event.MOUSEMOVE) } function placeAlerts(){ var alerts=document.getElementById('alerts').getElementsByTagName('div'); var len=alerts.length; var x=0; var y=300; var w=document.body.clientWidth; var h=document.body.clientHeight; for(var i=0;i<len;i++){ alerts[i].style.zIndex=i+100; alerts[i].getElementsByTagName('h3')[0].onmousedown=""; alerts[i].getElementsByTagName('input')[0].onclick="";
if(window.pageYOffset){ alerts[i].style.top=y+(window.pageYOffset)+'px' }else{ alerts[i].style.top=y+(document.documentElement.scrollTop)+'px' } alerts[i].style.left=(w / 2)- (343 / 2) + x +'px'; x=x+15; y=y+15; if(i==len-1){ var h3=alerts[i].getElementsByTagName('h3')[0]; var but=alerts[i].getElementsByTagName('input')[0]; but.onclick=function(){ this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode); var alerts=document.getElementById('alerts').getElementsByTagName('div'); if(alerts.length==0){ window.onscroll=""; } placeAlerts(); } h3.onmousedown=function(event){ this.parentNode.setAttribute('id','active_alert'); var event=(event)?event:arguments[0]; mouseXY(event); start_x=posX; start_left=document.getElementById('active_alert').style.left.replace('px',''); adjust=posX-start_left; document.onmousemove=function(event){ var event=(event)?event:arguments[0]; mouseXY(event); var obj=document.getElementById('active_alert'); obj.style.left=posX-adjust+'px' obj.style.top=posY-5+'px' }; } h3.onmouseup=function(){ document.onmousemove=""; this.parentNode.setAttribute('id',''); } } } }
Function Call
msgBox("You have done something real bad! So Bad, oh so bad!","Ya shoudn't of done it boy!")
i wrote a very simple HTML page to test some DOM features between Mozilla and IE. Mozilla is perfect everything went fine and i got the childNodes from my custom tag ( this tag i named <blah> ), inside this tag there is two <span>, that i retrieved. But with IE i really could figure out how its done! Code:
I try to associate DOM nodes with other objects. Assigning custom properties to DOM nodes works in Firefox and Safari. It also works with HTML nodes in IE6. However, it appears not to work with XML nodes that are part of trees returned by XMLHttpRequest. How can I work around this limitation? For XML nodes, I need to be able to associate at most one object with each node.
The syntax I am using is node.customproperty = value
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 want to have a custom button change appearance when pressed and then call a function and change back to its original appearance when released.
here's what i have now, which works mostly. "drop" is my handler for the button, its argument tells me which button was pressed. i have a number of these buttons and they are organized in a table.
there is a fair amount of superstition here, the result of many tiny experiments i ended up with this which seems to work best: Code: