Trap A Click At The Div Level?
Jan 3, 2010
At certain times I need to prevent the user from clicking on elements in a div. I've tried giving the div an onclick that simply returns false, but the clicks still get through. In the simplified code below, the onclick is hardwired, but in real life it would be assigned dynamically. In this example, when I click the link to Google, I get the "yo" alert, but the Google page still loads. If it were just one link, I could disable it directly. But I'll be dealing with pages with lots of links on them. How do I do this??
[Code]...
View 2 Replies
ADVERTISEMENT
Aug 13, 2009
I am trying to trap the shift+click event of a DIV. Works in IE and Chrome but not in Firefox. Purpose of the code: The DIV provides a hidden link (no decoration) for an editor who wants to edit content. The DIV ignores a simple click (meaning a click without a combination of the shift key) to avoid accidental access to the casual surfer. Here is the logic of the code: DIV is clicked. call function to check for the shift key being depressed if the shift key were depressed during the "click", initiate access. If the shift key were not depressed, ignore the "click" Here is the HTML code:
[Code]...
View 2 Replies
View Related
May 19, 2009
I want that when i click on a other main item that the other will close. Now it still keep open and then ill get a long menu list. How do i do it , i dont have js experience.
[Code]...
View 2 Replies
View Related
Jan 7, 2009
I am trying to turn a single level flyout menu into a multi level one.
It uses a dt for the title, and a ul within the dd for the menu items. The dd opens to the right of the dt.
The problem is that the second level menu (a dl within an li within another dl) [URL] - flyout4 & subflyout5.
The z-index is increased each time. I just can't figure why the area is limited.
javascript, css & html follow -
Code JavaScript:
/** FLYOUT = vertical dropdown **/
var Flyout = {
DDSPEED:10,
[Code].....
View 1 Replies
View Related
Dec 1, 2009
I would like to trap the MouseOut event of a DIV.
The problem is that the DIV contains an UL.
When the mouse enters the UL, it triggers the MouseOut for the DIV container. I only want to trigger an action when the mouse leaves the outer edge of the DIV.
View 1 Replies
View Related
Aug 1, 2011
<input TYPE="text" USERNAME="username">
How do validate the input to trap space entry.
i.e. []= space
Tom[]Smith
is ok
Tom[]H[]Smith
But not
[][][]
only.
if((document.form.nickname.value)=="") does not work.
View 2 Replies
View Related
May 30, 2011
I am trying to use the following code to trap JavaScript errors. It seems to work well in IE and FF but not in Opera. I expect I must have turned it off somewhere in the "preferences" but I can't find where. I'm using Opera 10.10.
Code:
<script type="text/javascript">
function Err() {[code].....
View 9 Replies
View Related
Jul 20, 2005
I want to trap the window.close() event when the user clicks on the close button of the browser using javascript. Can anyone shed light on this problem ?
View 1 Replies
View Related
Jun 5, 2006
I have been searching for a way to trap changes done to the document object (mainly by the function document.write();).
Example of code that doesn't work:
function myFunction() {
ed.document.onchange = doFunction(document.body.innerHTML);
ed.document.open();
ed.document.write('Hello');
ed.document.close();
}
function do_function(body) {
alert(body);
}
It only fires when the page loads, not when I change the text. You are free to use any event that works, but i think onchange was the one to fit this problem. The alert will write the initialpage, but will never write the tekst 'Hello' that is the new change.
Any javagurus out there know a solution to pick up any fired events triggered by document.write();
View 6 Replies
View Related
Nov 4, 2011
Im having trouble trying to access some values of the response from an API service. My code to connect and output for each item is working Ok getting the name and age. But I can't work out how to get the image urls.Clutching at straws I thought I could just target the first value stored using $imageURL = item.images['url'][0] but that fails.
Code:
$.getJSON("http://api-address", function(data) {
var html = '';
[code]....
View 3 Replies
View Related
Sep 21, 2011
If I wanted just the first level of ancestors inside a div what selector would I use?
<div>get me</div>
<div>get me</div>
<div>get me<div>don't get me</div></div>
<div>get me</div>
View 2 Replies
View Related
Jun 17, 2009
3-level dropdown box: [URL]. Now in this dropdown menu if you select:
Category > Cars
Sub category Cars for Sale
Sub Sub Category Ibiza
What I want to do is two things:
1)Place a value on all the Sub Sub Category(ies) so for example the value of Ibiza I want to = 55
2)Then Grab that value? How would I get that value and grab it from POST?
View 1 Replies
View Related
May 3, 2010
I would like to use the menu that is linked below. I implemented it on my website but I discovered that it can only go 2 levels deep. I would like it to go one more level and I think that would be done in the javascript but I can't tell for sure. Could someone steer me in the right direction? [URL]
View 2 Replies
View Related
Mar 18, 2011
IE shows loads the page with errors in the script. It says:
'guid' is NULL or not an object
View 1 Replies
View Related
Jun 28, 2009
Like in the topic: I was wondering if you know a way to do it nice and clean.
View 3 Replies
View Related
Feb 26, 2006
Can someone direct me to a 3 level menu with the top level being images....
View 4 Replies
View Related
May 26, 2006
I've got a document that I want to ensure always get loaded into the
top level document and not into a frame or iframe. I've got it figured
out how to detect if the document is loaded into a frame. But what I
want to happen is the HTML content in the iframe to be displayed in the
top level document w/o a return trip to the server.
Here's what I'm thinking:
function forceTopLevelDocument() {
if (top != self) {
//load the HTML from child document into parent document
//without a return trip back to the server
}
}
What I can't figure out is how to take the document loaded into a child
frame and push it's contents up into a parent frame.
View 16 Replies
View Related
Feb 4, 2011
I have been searching around to see if it is possible to have a 5 level jQuery Cascading dropdown, so far I have 3 levels working but 4 and 5 will not.I have searched around and all I have found are only 3 level jQuery Cascading dropdown.
View 2 Replies
View Related
Jun 14, 2011
i want to collapse all level at load in this site : [URL]
View 1 Replies
View Related
Jan 6, 2010
I'm grabbing an XML file with jQuery like this:
$
document
.ready
[code]....
View 8 Replies
View Related
Apr 21, 2009
I want to use this menu but i have so many main items that there are 2 rows. The first row is always on top. How can i get the second level menu to be on top of the fisrt item menu-item1 menu-item2 menu-item3 menu-item4 menu-item5 menu-item6 menu-item7 menu-item8 menu-item9
View 2 Replies
View Related
Feb 13, 2010
Given the following markup
<div id="menu">
<ul>
<li><a id="home" href="#">Home</a></li>
<li>
<a id="about" href="#">About</a>
<div>
About sub menu
</div></li><li>
<a id="products" href="#">Products</a>
<div><h2>Books</h2>
<ul><li>ColdFusion</li>
<li>jQuery</li>
<li>CSS</li>
<li>HTML</li>
<li>Groovy</li>
<li>Hibernate</li> .....
How can I grab only the 1st level children of my node? I want direct decendents of menu only. My code below is grabbing all <li> which is going to be a problem.
(function($){
$.fn.extend({
myplugin: function(options){
return this.each(function(){
// the object we are working with
var obj = $(this);
// get a list of menu items
var menuItems = $('li',obj);
});
}});
})(jQuery);
View 2 Replies
View Related
Feb 22, 2010
Am having a fiddle with the following for a while now and am not getting anywhere - also not knowing if what i am trying is actually the best / fastest way... What i have is the following menu
<ul>
<li>Test</li>
<li>Test
[code].....
View 11 Replies
View Related
Feb 2, 2010
Here is a list of block-level elements: [URL]. What is the best way to detect these using JavaScript?
View 5 Replies
View Related
Feb 13, 2007
Tested in IE6 and Firefox. Hover on main menu items, sub-items are displayed. Main menu items are not required to have sub items.
MenuTree.xml
<?xml version="1.0" ?>
<menu>
<main>
<text>First</text>
<sub>
<text>Anything</text>
<link>links/anything.html</link>
</sub>
<sub>
<text>Everything</text>
<link>links/everything.html</link>
</sub>
<sub>
<text>Nothing</text>
<link>links/nothing.html</link>
</sub>
</main>
<main>
<text>Second</text>
<link>links/apples.html</link>
</main>
<main>
<text>Third</text>
<sub>
<text>Something</text>
<link>links/something.html</link>
</sub>
</main>
<main>
<text>Fourth</text>
<link>links/oranges.html</link>
</main>
</menu>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
var response = "";
var nContainer = "";
var mainItemsText = [];
var mainItemsLink = [];
var subItemsText = [];
var subItemsLink = [];
var mainItemsWithSubs = [];
var IE = true;
if (navigator.appName != "Microsoft Internet Explorer"){IE = false}
function hideSubs(nMain){
var nSubs = nMain.getElementsByTagName('dd');
for (i=0; i<nSubs.length; i++)
{
nSubs[i].style.display = 'none'
}
}
function showSubs(nMain){
var nSubs = nMain.getElementsByTagName('dd');
for (i=0; i<nSubs.length; i++)
{
nSubs[i].style.display = ''
}
}
function setHoverDisplay(){
if (IE)
{
for (i=0; i<mainItemsWithSubs.length; i++)
{
for (n=0; n<subItemsText[i].length; n++)
{
nContainer.childNodes[mainItemsWithSubs[i]].childNodes[n+1].style.display = 'none'
nContainer.childNodes[mainItemsWithSubs[i]].onmouseover = function(){showSubs(this)}
nContainer.childNodes[mainItemsWithSubs[i]].onmouseout = function(){hideSubs(this)}
}
}
}
else {
for (i=0; i<mainItemsWithSubs.length; i++)
{
for (n=0; n<subItemsText[i].length; n++)
{
nContainer.childNodes[mainItemsWithSubs[i]+1].childNodes[n+1].style.display = 'none'
nContainer.childNodes[mainItemsWithSubs[i]+1].onmouseover = function(){showSubs(this)}
nContainer.childNodes[mainItemsWithSubs[i]+1].onmouseout = function(){hideSubs(this)}
}
}
}
}
function buildMenu(){
nContainer = document.getElementById('menuContainer');
mainItemsWithSubs = [];
var n = 0;
for (i=0; i<mainItemsText.length; i++)
{
var nItem = document.createElement('dt');
var nLink = document.createElement('a');
nItem.appendChild(nLink);
nLink.appendChild(document.createTextNode(mainItemsText[i]));
if (mainItemsLink[i] != undefined)
{
nLink.setAttribute('href',mainItemsLink[i]);
}
else{
nLink.setAttribute('href',"#");
nLink.onclick = function(){return false;}
mainItemsWithSubs[n++] = i;
}
nContainer.appendChild(nItem);
}
for (i=0; i<mainItemsWithSubs.length; i++)
{
for (s=0; s<subItemsText[i].length; s++)
{
nItem = document.createElement('dd');
nLink = document.createElement('a');
nItem.appendChild(nLink);
nLink.appendChild(document.createTextNode(subItemsText[i][s]));
nLink.setAttribute('href',subItemsLink[i][s]);
if (IE){nContainer.childNodes[mainItemsWithSubs[i]].appendChild(nItem)}
else {nContainer.childNodes[mainItemsWithSubs[i]+1].appendChild(nItem)}
}
}
setHoverDisplay();
}
function parseResponse(){
var n = 0;
var s = 0;
var mainItems = response.getElementsByTagName('main');
if (IE)
{
for (i=0; i<mainItems.length; i++)
{
mainItemsText[n] = mainItems[i].firstChild.text;
if (mainItems[i].childNodes[1].nodeName == "link")
{
mainItemsLink[n] = mainItems[i].childNodes[1].text;
}
n++;
}
}
else {
for (i=0; i<mainItems.length; i++)
{
mainItemsText[n] = mainItems[i].childNodes[1].firstChild.data;
if (mainItems[i].childNodes[3].nodeName == "link")
{
mainItemsLink[n] = mainItems[i].childNodes[3].firstChild.data;
}
n++;
}
}
for (i=0; i<mainItems.length; i++)
{
if (IE && mainItems[i].childNodes[1].nodeName == "sub")
{
subItemsText[s] = [];
subItemsLink[s] = [];
for (n=0; n<mainItems[i].getElementsByTagName('sub').length; n++)
{
subItemsText[s][n] = mainItems[i].childNodes[n+1].childNodes[0].text;
subItemsLink[s][n] = mainItems[i].childNodes[n+1].childNodes[1].text;
}
s++;
}
if (!IE && mainItems[i].childNodes[3].nodeName == "sub")
{
subItemsText[s] = [];
subItemsLink[s] = [];
var subs = mainItems[i].getElementsByTagName('sub');
for (n=0; n<subs.length; n++)
{
subItemsText[s][n] = subs[n].childNodes[1].firstChild.data;
subItemsLink[s][n] = subs[n].childNodes[3].firstChild.data;
}
s++;
}
}
buildMenu();
}
function getMenuTree(){
var request = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
request.onreadystatechange = function()
{
if (request.readyState == 4)
{
if (request.status == 200)
{
response = request.responseXML;
parseResponse();
}
else {alert('Error MenuTree.xml '+ request.statusText)}
}
}
var forceGET = "?n="+ parseInt(Math.random()*999999999);
request.open("GET", "MenuTree.xml"+forceGET, true);
request.send(null);
}
onload=getMenuTree;
</script>
<style type="text/css">
dt {background-color:#b0c4de;text-indent:5px}
dd {background-color:#87ceeb}
a {color:#00008b}
</style>
</head>
<body>
<div id='menuContainer' style='border:1px solid black;background-color:#afeeee;height:200px;width:150px;font-size:12pt;padding:5px;overflow:auto;font-family:arial;font-weight:bold;line-height:140%'>
</div>
</body>
</html>
View 6 Replies
View Related
Apr 12, 2010
I'm trying to make 3 drop downs (based off of mysql tables), to narrow down the selection. Source, School, and Program. So when when they select SOURCE(source), all the SCHOOLs in drop2 will be based on the SOURCE selected in the previous dropdown, and whatever school(cid) is selected, the program will be based off that school(cid) and display all the programs for that school. I've google'd high and low for something, and no avail. Here is what I have, I am just trying to make 3 drop downs narrow in, without pressing submit (I am new to ajax and javascript etc) The issue may be in that java part, I've look in the php and mysql, but nothing.
PHP Code:
<table width="517" border="1"> <tr>
<td width="87">Source:</td> <td width="414">
<? echo'<select name="source" onChange="showUser(this.value)">
<option value="">--Select--</option><?php while() { } ?>'; .....
My javascript
Code:
var xmlhttp;
function showUser(str){
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null){
alert ("Browser does not support HTTP Request");
return;
} .....
Right now, the results display in a table, I don't want that - I need them to display as results in the next dropdown.
View 1 Replies
View Related