JavaScript - Enabling Javascript
Dear Experts
Whenever I use Javascript in my web and run it into Internet Explorer then it displays following messagebar To help protect your security, Internet Explorer has restricted this file from showing active content that could access your computer... If I do not allow blocked contents then nothing is displayed. My question is how to enable blocked contents through codes in html page. If it is not possible then why should we us javascript. Please help me to remove this confusion. Similar TutorialsI have an e-script that agents use on a daily basis as their script. I have a page, that when a yes or no answer is given, it enables AND disables buttons accordingly. I am having some issues with the code. In this example, the agent must ask if the customer has insurance. They must select yes or no, from the radio buttons. If yes is selected, all buttons need to activate, or ungray. If they select no, I need the buttons to gray out. This needs to function both ways, meaning, if they first choose yes, the buttons light up. But, if they customer wasn't sure, and they in fact do not have insurance, and the agent clicks the no button, it then needs to gray the buttons out again. I have the first part of this code working, I am able to enable the buttons when clicking yes. However, I cannot get it to work reverse, when I click the no button. They stay enabled. Here is my current DF coding. Thanks in advance!!! I am stuck! Code: <script type="text/javascript"> window.onload=function() { df=document.forms[0]; df[1].disabled=true; df[0].onclick=function(){ df[1].disabled=(df[1].disabled)?false:true; } df=document.forms[0]; df[4].disabled=true; df[1].onclick=function(){ df[4].disabled=(df[4].disabled)?false:true; } df=document.forms[0]; df[5].disabled=true; df[4].onclick=function(){ df[5].disabled=(df[5].disabled)?false:true; } df=document.forms[0]; df[6].disabled=true; df[5].onclick=function(){ df[6].disabled=(df[6].disabled)?false:true; } df=document.forms[0]; df[9].disabled=true; df[6].onclick=function(){ df[9].disabled=(df[9].disabled)?false:true; } df=document.forms[0]; df[10].disabled=true; df[9].onclick=function(){ df[10].disabled=(df[10].disabled)?false:true; } df=document.forms[0]; df[12].disabled=true; df[10].onclick=function(){ df[12].disabled=(df[12].disabled)?false:true; } df=document.forms[0]; df[15].disabled=true; df[12].onclick=function(){ df[15].disabled=(df[15].disabled)?false:true; } df=document.forms[0]; df[18].disabled=true; df[17].onclick=function(){ df[18].disabled=(df[18].disabled)?false:true; } df = document.forms[0]; df[2].onclick = function() { df[17].disabled = !df[17].disabled; df[18].disabled = !df[18].disabled; df[19].disabled = !df[19].disabled; df[20].disabled = !df[20].disabled; } df[17].disabled = true; df[18].disabled = true; df[19].disabled = true; df[20].disabled = true; } df = document.forms[0]; df[3].onclick = function() { df[17].disabled = !df[17].disabled; df[18].disabled = !df[18].disabled; df[19].disabled = !df[19].disabled; df[20].disabled = !df[20].disabled; } df[17].disabled = true; df[18].disabled = true; df[19].disabled = true; df[20].disabled = true; </script> The buttons are DF's 17,18,19 & 20. When DF 2 is selected, I need them to enable. When DF 3 is selected, I need them to disable. I have more than just those I need to fix, but if I can get that one working, I can take it from there. Thanks! Hi, I'm writing an android application to login into a website by injecting javascript into the HTML. So far it works for inputting the username and password, but I can't enable the submit button. Here is my code Code: "javascript: document.getElementById('user').value = '"+username+"'; document.getElementById('pass').value = '"+password+"'; document.getElementsById('submit').disabled = false;" Here is the code from the website concerning the submission form. Does anybody have any idea why this isn't working? Thank you for any help! Code: <form id="loginForm" name="query" method="post" action="/login/" enctype="application/x-www-form-urlencoded" autocomplete="off"> <p> <input type="hidden" name="one" value="wiscmail.wisc.edu" /> <input type="hidden" name="two" value="WiscMail Login" /> <input type="hidden" name="creds_from_greq" value="1" /> <input type="hidden" name="three" value="1" /> <input type="hidden" name="four" value="a5" /> <input type="hidden" name="five" value="GET" /> <input type="hidden" name="six" value="wiscmail.wisc.edu" /> <input type="hidden" name="seven" value="L2xvZ2lu" /> <input type="hidden" name="relay_url" value="https://wiscmail.wisc.edu/PubCookie.reply" /> <input type="hidden" name="eight" value="YXBwdXJsPXdpc2NtYWlsLndpc2MuZWR1L2xvZ2lu" /> <input type="hidden" name="fr" value="NFR" /> <input type="hidden" name="hostname" value="wiscmail.wisc.edu" /> <input type="hidden" name="nine" value="1" /> <input type="hidden" name="file" value="" /> <input type="hidden" name="flag" value="0" /> <input type="hidden" name="referer" value="(null)" /> <input type="hidden" name="post_stuff" value="" /> <input type="hidden" name="sess_re" value="0" /> <input type="hidden" name="pre_sess_tok" value="1714500944" /> <input type="hidden" name="first_kiss" value="1320154779-954466" /> <input type="hidden" name="pinit" value="0" /> <input type="hidden" name="reply" value="1" /> <input type="hidden" name="create_ts" value="1320154779" /> <label for="user">NetID</label><input type="text" id="user" name="user" size="20" tabindex="1" value="" /> </p> <p class="info"><a tabindex="4" href="/redirect/help-whatisit">What is my NetID?</a> (ie. bbadger)</p> <p><label for="pass">Password</label><input type="password" id="pass" name="pass" tabindex="2" maxlength="36" value="" /> </p> <p class="info"><a tabindex="5" href="/redirect/mynetid-reset">Forgot your password?</a></p> <p><label for="submit" class="invisible">Submit</label><input tabindex="3" class="submitButton" type="submit" id="submit" value="Login" /></p> </form> Hi everybody... I have some radio group boxes and according to select one of the values, the other values in another radio boxes should be enabled and checked. In the onClick method of each radiobox i call a setDefault() function to reset the value of radioboxes.... (e.g for (i;i<document.NPOrder.pSubstrate.length;i++){ document.NPOrder.pSubstrate[i].disabled=false; document.NPOrder.pSubstrate[i].checked=false; } and after that i disabled and checked the other's value...) Problem: The code in setDefault() doesn't work properly and after disabling the radios, i can't enable them again Please help me and thanks in advance... Hany Hi there, This is my request. I don't know if it CAN be done via JS, but it just seemed likely it could: Basically, I have a table echoed out by PHP: PHP Code: while($row = mysql_fetch_array($result)){ echo "<tr>"; echo "<td>".$row['Name']."</td>"; echo "<td>".$row['gig_count']."</td>"; echo "<td>" .$row['dob']."</td>"; echo "<td>".$row['Mail']."</td>"; echo "<td><a href=\"/records/add_gigs.php?id=".$row['Member_ID']."&?name=".$row['Name']."\"><button class=\"submit\">Add new Gig</button></a></td>"; echo "<td><a href=\"/certsend.php?name=".$row['Name']."&?mail=".$row['Mail']."\"><button class=\"submit\">Make Certificate!</button></a></td>"; echo "</tr>"; And if the value of gig_count is less than 20, then the 'make certificate' button will be disabled. Once gig_count is 20 or more, then it is re-enabled for that particular row. Any code towards this is greatly appreciated. i have this slideshow, Swiss Army Image slideshow i got from DDrive. it has forward and back buttons that are disabled unless the Play/Stop button is in Stop mode. i cannot for the life of me figure out how to enable the buttons always. please can someone help? i have a maniac client who's now threatening not to pay because of this one thing!!! installation: http://cssphpmysql.com/dev/westermancm/library2.html js: http://cssphpmysql.com/dev/westermancm/js/swissarmy.js thanks so much! GN hi.. i have a jsp page in which there is a table. the number of rows is variable and depends on a pre-defined query. every row has 2 editable textboxes which are initially disabled. i need to activate these textboxes according to the radio button which corresponds to the particular row in question. can anybody pls tell me how to do that. the code that i have written is as follows.if there is any tweaking to be done pls suggest the same. code: <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@page import="java.util.ArrayList" %> <%@page import="DTO.UserGroupDTO"%> <html> <head> <script type="text/javascript">} funtion enable(){ document.getElementById("inp1").disabled=false; document.getElementById("inp2").disabled=false; } function disable(){ document.getElementById("inp1").disabled=true; document.getElementById("inp2").disabled=true; } </script> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Update User Group Inquiry Results</title> </head> <body bgcolor="#aabbcc"> <center> <h3>Update User Group Inquiry Results</h3><br><br> <%ArrayList arrayList=(ArrayList)request.getAttribute("myList"); ArrayList list; int size=arrayList.size(); Integer groupId=null; String userGroupName=null; String description=null; %> <form action="/test/BankServlet"> <table style="color: highlight" border="5"> <% if(!(arrayList.isEmpty())){%> <tr><th>Group ID</th><th>User Group Name</th><th>Description</th><th>Selection</th></tr> <% for(int i=0;i<size;i++){ UserGroupDTO userGroupDTO=(UserGroupDTO)arrayList.get(i); userGroupName=userGroupDTO.getUserGroupName(); groupId=userGroupDTO.getGroupId(); description=userGroupDTO.getDescription(); %> <tr> <td><%out.println(groupId); %></td> <td><input id="inp1" disabled="disabled" value="<% out.println(userGroupName); %>"></td> <td><input id="inp2" disabled="disabled" value="<%out.println(description); %>"> </td> <td> <input type="radio" name="radio2" value="<%=groupId %>" onclick="enable()"> </td> </tr> <% } } else{ out.println("No match found"); } %> <tr> <td><input type="hidden" name="strTitle" value="UpdateUserGroup"></td> </tr> <tr> <td><input type="hidden" name="value" value="<%=groupId%>"></td> </tr> </table><br> <input type="submit" value="Update User Group" style="background-color: gray"> </form> <form action="/test/jsp/UserGroup.jsp"> <input type="submit" value="Go Back to User Group Operations Page" style="background-color: gray"> </form> <br><br><br><br> </center> </body> </html> I want to have another go at Javascript. I have several books on the subject but I find that my eyesight is a major problem. Therefore I want to try an on-line solution, preferably free. I have Googled, but there are so many that I am almost dizzy with the choices. Perhaps someone could recommend one. Not too fussy visually. My knowledge is VERY basic. Frank Hello! I am trying to find a script that allows you to open multiple browser tabs and then close each of those tabs, either one by one or all at once. Does anyone know how to do this please? Thanks so much for your help. Does anyone know how to make URL links that use Javascript still work when users have Javascript disabled on their browser? The only reason I'm using JS on a URL is because my link opens a PDF file, and I'm forcing it not to cache so users have the latest version. I tried the <script><noscript> tags, but I'm not sure if I'm using it correctly, as my URL completely disappears. Below is my HTML/Javascript code: <p class="download"> <script type="text/javascript">document.write("<span style=\"text-decoration: underline;\"><a href=\"javascript:void(0);\" onclick=\"window.open( 'http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf?nocache='+ Math.floor( Math.random()*11 ) );\" >The Child Magazines Media Kit</a></span> (PDF 1 MB) ");</script> <noscript><span style="text-decoration: underline;"><a href="http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf" >The Child Magazines Media Kit</a></span> (PDF 1 MB)</noscript> </p> Thanks for any help, Michael Hi, I have the following code snippet: test.html ====== <script language="javascript" type="text/javascript"> var testVariable = "test"; </script> <script language="javascript" type="text/javascript" src="test.js"> </script> test.js ===== var testVariable = window.top.testVariable; In firefox, I'm able to access testvariable defined within test.html in test.js. But in chrome, test.js couldnot get the window.top.testVariable field defined in test.html. Can any one please let me know how i can make it work in chrome?. Am i missing something here?. Hi Guys, I am new at JavaScript and start to do some tutorials.What I am trying to do here is prompting user to input a name and if the name was valid the page(document) will display with all objects like the button.But if user enter a wrong name then the button will be disabled! I create the following code but it did not work <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Web Project</title> <script language="JavaScript" type=""> function changeColor(){ document.bgColor = "Gray"; } </script> </head> <body> <script language="JavaScript" type="text/javascript"> var person = ""; person = prompt('What is Your Name:'); if (person == "Foo") { document.write("<h1 />Welcome " + person); document.bgColor = "Yellow"; } else { document.write("<h1 />Access Denied!!!!"); document.bgColor = "Red"; document.getElementById("gree").disabled = true; } </script> <div> <p/><input id="gree" type="button" value="Gray " onClick="changeColor();"> </div> </body> </html> as you can see I used the: document.getElementById("gree").disabled = true; but it did not work , could you please give an idea how I can solve this problem? Thanks I want to insert this js snippet Code: function addText(smiley) { document.getElementById('message').value += " " + smiley + " "; document.getElementById('message').focus(); return false; } to a loaded iframe with name&id chtifrm. I can access it & change embed something in its html via using something like: Code: $(parent.chtifrm.document.body).append('<div id=\"smly\" style=\"cursor:pointer;float:left;top:200px;display:none;position:absolute;\"><\/div>'); .... Code: parent.chtifrm.document.getElementById('chatbox_option_disco').style.display == 'none' but how do I insert js in the head of loaded iframe? I got an index.php Code: <html> <form action="bacakomik.php" method='post'> <select name="kodekomik"> <option value='../komik1/|23'>Judul Komik1</option> <option value="../komik2/|20">Judul Komik2</option> <option value="../komik3/|10">Juduk Komik3</option> <option value="../komik4/|20">Judul Komik4</option> </select> <input type="submit" /> </form> <?php echo ('<select>'); echo ('<option value= "'.$i.'">'.'Page '.$i.'</option>'); echo ('</select>'); ?> </html> As you can see, each of the option brings specific value "../komik1/|23" komik1 is a directory | is a delimiter 23 is the pages in one chapter and can be considered also as how many images are there on a specific directory This is my bacakomik.php Code: <?php $dirkomik = $_POST['kodekomik']; $exploded = explode("|", $dirkomik); echo ($exploded[0]); //picture directory echo ("<br>"); echo ($exploded[1]); //total page in the comic $pagecount = (int)$exploded[1]; //Take last posted value, process it right away echo ('<FORM name="guideform"> '); echo ('<select name="guidelinks">'); $i=1; do { echo ('<option value= "'.$i.'">'.'Page '.$i.'</option>'); $i= $i+1; }while($i <= $pagecount); //Printing option and select echo ("</select>"); ?> <input type="button" name="go" value="Go!" onClick="document.getElementById('im').src=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value+'.png';"> </FORM> <img src="img0.jpg" id="im"> With the current code on bacakomik.php, I only can change the img src of id "im" in the same directory only. What I want is that the Javascript could "add" the "$exploded[0]" variable so that the picture can be loaded from different directory. Anyone can do this? I believe that the fix should be somewhere on input tag inside OnClick, or do you know where? Anyway, I found this on the net http://p2p.wrox.com/php-faqs/11606-q...avascript.html Please help me to those who can... Hey, I've got to make the values of some textboxes change the co-ordinates of my sprite on a canvas and havent a clue on how to do it, Here is my form with the two textboxes and submit button: <form> x: <input type="text" name="x" /><br /> y: <input type="text" name:"y" /><br /> <input type="submit" value="Submit"/><br /> </form> And i need it so that they change the values of these: //this shows where my sprite will start on the canvas var block_x; var block_y; searched the internet for hours and cant really find anything i understand or works. any help is much appreciated Hi Guys I am trying to modify the functionality of my page. I want to be able to activate this piece of code using another javascript function. This is the code I want to activate: Code: <script type="text/javascript"><!-- $('#button-cart').bind('click', function() { $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea, .date_data input[type=\'text\']'), dataType: 'json', success: function(json) { $('.success, .warning, .attention, information, .error').remove(); if (json['error']) { if (json['error']['warning']) { $('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); $('.warning').fadeIn('slow'); } for (i in json['error']) { $('#option-' + i).after('<span class="error">' + json['error'][i] + '</span>'); } } if (json['success']) { $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); $('.success').fadeIn('slow'); $('#cart_total').html(json['total']); $('html, body').animate({ scrollTop: 0 }, 'slow'); } } }); }); //--></script> And this is how I want the format of the function to be: function testsession() { if there is a session called 'hiredate' { activate the script above } else { var el = document.getElementById("product_data"); } } I just dont know how to write this in javascript Could you help me if possible please All -- I have a JavaScript config file called gameSetting.js which contains a bunch of variables which configures a particular game. I also have a shared JavaScript library which uses the variables in gameSetting.js, which I include like so: <script type="text/javascript" src="gameSetting.js" ></script> <script type="text/javascript" src="gameLibrary.js" ></script> In gameSetting.js I have: $(document).ready(function() { // call some functions / classes in gameLibrary.js } in Firefox, Safari, and Chrome, this works fine. However, in IE, when it's parsing gameSetting.js, it complains that the functions that live in gameLibrary.js aren't defined. When it gets to parsing gameLibrary.js, the variables in gameSetting.js are reported as not being defined. I've tried dynamically bootstrapping the gameLibrary file using this function in document.ready for dynamic load... $.getScript("gameLibrary.js"); However, the same problem still happens in IE, where when it parses the files individually it's not taking into context the file/variables that came before, so it's not an out of load order problem. My options a 1) collapsing all the functions in gameLibrary.js and variables in gameSetting.js into one file. However, this is not practical because this is dealing with literally hundreds of games, and having a gameLibrary.js in ONE location for ONE update is what makes most logical sense. 2) figure out a way to get this to work where variables in file1 are accessible to file2 in IE (as it seems they are in other browsers). jQuery seems to be able to have multiple plugins that all refer to the based jQuery-1.3.2.js, so I know there is a way to get this to work. Help appreciated. Nero I wrote a log function that took note of various function calls. Thinking that functions are first class objects, and objects have properties, I made the name of each logged function a property of that function, e.g., brightenInnerPara.name = "brightenInnerPara"; Every browser I tried (Firefox, MSIE, Opera, Chrome, Safari) accepted the assignment, no problem. In Firefox and MSIE, the result was what I wanted: brightenInnerPara.name == "brightenInnerPara" But in the others, the result was: brightenInnerPara.name == null Question 1. Which Javascript is correct here? I favor Firefox and MSIE, not merely because they were willing to give me what I wanted, but also because it makes no sense to accept an assignment statement without throwing an error and then give it a null semantics, like Chrome, Opera, and Safari did. I found a workaround, using assignments like this: brightenInnerPara.prototype.name = "brightenInnerPara"; To my surprise, that worked in every browser. But I don't know why. It seems that such assignments are enough to cause each function to have its own distinct prototype. Question 2. Just how inefficient is my workaround, and why does it work? Hi everyone, I'm trying to generate a drop down list using a supplied xml form with an xsl sheet. Because xsl lacks commands that will allow me to create repetitive <options> I am using javascript. A sample xml file that I am using is bellow. Code: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="a.xsl"?> <Country> <California> <County>San Diego</County> <County>Los Angeles</County> </California> <Nevada> <County>Reno</County> <County>Las Vegas</County> </Nevada> </Country> The xsl file that I'm using is show below. Code: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head></head> <body> <p>This loaded</p> <form> <select name='County'> <script type="text/javascript"> var i=3; while(i > 0){ document.write("<option><xsl:value-of select='Country/California/County["); document.write(2); document.write("]'/></option>"); i--; } </script> </select> </form> <script type="text/javascript"> var i=3; while(i > 0){ document.write("<xsl:value-of select='Country/California/County["); document.write(2); document.write("]' /> <br />"); document.write("<xsl:value-of select='Country/California/County[2]'/><br />"); i--; } </script> </body> </html> </xsl:template> </xsl:stylesheet> Bassically all I'm trying to do is list the counties under california. My problem is that the javascript will print the list no problem but it only prints san diego even if my xpath index = i, is set to two. When i is set to 2, it should display Los Angeles. The following sample code will display Los Angeles Code: document.write("<xsl:value-of select='Country/California/County[2]' />"); However when the document has i = 1, it should display san diego. Unfortunately when i use i = 2 and write ... Code: document.write("<xsl:value-of select='Country/California/County[" document.write(i); document.write("]' />"); or even Code: document.write("<xsl:value-of select='Country/California/County["); document.write(2); document.write("]' />"); The xsl sheet will display san diego instead. If the code is used without brackets you can see that everything is being displayed correctly ... for instance writting Code: document.write("xsl:value-of select='Country/California/County[" document.write(i); document.write("]' /"); will result in .. Code: xsl:value-of select='Country/California/County[2]' / Why is xsl doing this to me? Hi everyone, can someone please help me to find a way to rewrite this code function evenorodd( form ) { var x = new Number( form.x.value ); if( isNaN( x ) || x == "" ) { alert( "Not a number or no value entered" ); return ""; } for( var i = 0; i <= x; i++ ) ( i % 2 == 0 ) ? alert( i + " is even!" ) : alert( i + " is odd!" ); } the purpose is to show an alert box with a odd or even number Thanks in advanced! I have a little problem, i don't know what the problem is so please help me! What i want the page to do is that you have 2 buttons that you can click. One button you click to get points, when you have 15 points you can upgrade autoclick with 0.1 per second Thank you in Advance ) [/quote][/code] <html> <head> <title>Help/title> </head> <body> <p>Your Points:</p> <p id"Points">0</p> <button onclick="Click()">Click</button> <button onclick="AutoClickBuy()">Buy Auto-Click</button> </body> <script type="text/javascript"> function Click() { var newValue = parseInt(document.getElementByID("Points").innerHTML) +1; document.getElementByID("Points").innerHTML = newValue; } function AutoClickBuy() { var PointsValue = parseInt(document.getElementByID("Points").innerHTML); if (PointsValue > 14) { var newValue = parseInt(document.getElementByID("Points")innerHTML) - 15; document.getElementByID("Points").innerHTML = newValue; var myVar=setInterval(function(){CollectAutoClick()},1000); } } function CollectAutoClick() { var newValue = parseFloat(document.getElementByID("Points").innerHTML) + 0.1; document.getElementByID("Points").innerHTML = newValue; } </script> </html> Reply With Quote 01-26-2015, 06:52 PM #2 Philip M View Profile View Forum Posts Supreme Master coder! Join Date Jun 2002 Location London, England Posts 18,371 Thanks 204 Thanked 2,573 Times in 2,551 Posts Suggest you fix the errors in your markup first. See The W3C Markup Validation Service You have </body> wrongly placed. And an error here - <p id"Points">0</p> And here - <title>Help/title> BTW, when posting here please help us to help you by making it easier to view, copy, modify, test and debug your scripts by following the posting guidelines and wrapping your code in CODE tags. This means use the octothorpe or # button on the toolbar. Do please read the posting guidelines regarding silly thread titles. The thread title is supposed to help people who have a similar problem in future. Yours is useless for this purpose. Everyone here is looking for help with Javascript. |