JavaScript - Avoiding Activex Message Box Using Javascript
Hi
I'm using an ActiveX control in my html page.. Each time i load the page ie pops a message box to allow the activex to run or not . Is there any way to handle that message box using javascript. Or is there any other way to avoid that message box because each time the page loads i have to give yes and then proceed. By default i've to give yes is there any way to handle that using javascript. help me out please... Similar TutorialsI have an html file I've built with embedded Javascript (using ActiveX) that successfully reads a file on my local hard drive when I run the html file through my web browser (IE) locally. However, when I copy the html page up to a webserver and access it through the internet, it doesn't appear to be reading the local file. I'm assuming this can't be done because of security reasons? Am I correct in that? Is there any way using Javascript/ActiveX that you can get a webpage on the internet to access a file on the visitor's local drive? (other than cookies)
Firebug is giving me no error messages, but alert() message is never triggered. I want the alert() message defined below to alert what the value of the variable result is (e.g. {filter: Germany}). And it doesn't. I think the javascript breaks down right when a new Form instance is instantiated because I tried putting an alert in the Form variable and it was never triggered. Note that everything that pertains to this issue occurs when form.calculation() is called: markup: Code: <fieldset> <select name="filter" alter-data="dropFilter"> <option>Germany</option> <option>Ukraine</option> <option>Estonia</option> </select> <input type="text" alter-data="searchFilter" /> </fieldset> javascript (below the body tag) Code: <script> (function($){ var listview = $('#listview'); var lists = (function(){ var criteria = { dropFilter: { insert: function(value){ if(value) return handleFilter("filter", value); }, msg: "Filtering..." }, searchFilter: { insert: function(value){ if(value) return handleFilter("search", value); }, msg: "Searching..." } } var handleFilter = function(key,value){ return {key: value}; } return { create: function(component){ var component = component.href.substring(component.href.lastIndexOf('#') + 1); return component; }, setDefaults: function(component){ var parameter = {}; switch(component){ case "sites": parameter = { 'order': 'site_num', 'per_page': '20', 'url': 'sites' } } return parameter; }, getCriteria: function(criterion){ return criteria[criterion]; }, addCriteria: function(criterion, method){ criteria[criterion] = method; } } })(); var Form = function(form){ var fields = []; $(form[0].elements).each(function(){ var field = $(this); if(typeof field.attr('alter-data') !== 'undefined') fields.push(new Field(field)); }) } Form.prototype = { initiate: function(){ for(field in this.fields){ this.fields[field].calculate(); } }, isCalculable: function(){ for(field in this.fields){ if(!this.fields[field].alterData){ return false; } } return true; } } var Field = function(field){ this.field = field; this.alterData = false; this.attach("change"); this.attach("keyup"); } Field.prototype = { attach: function(event){ var obj = this; if(event == "change"){ obj.field.bind("change", function(){ return obj.calculate(); }) } if(event == "keyup"){ obj.field.bind("keyup", function(e){ return obj.calculate(); }) } }, calculate: function(){ var obj = this, field = obj.field, msgClass = "msgClass", msgList = $(document.createElement("ul")).addClass("msgClass"), types = field.attr("alter-data").split(" "), container = field.parent(), messages = []; field.next(".msgClass").remove(); for(var type in types){ var criterion = lists.getCriteria(types[type]); if(field.val()){ var result = criterion.insert(field.val()); container.addClass("waitingMsg"); messages.push(criterion.msg); obj.alterData = true; alert(result); initializeTable(result); } else { return false; obj.alterData = false; } } if(messages.length){ for(msg in messages){ msgList.append("<li>" + messages[msg] + "</li"); } } else{ msgList.remove(); } } } $('#dashboard a').click(function(){ var currentComponent = lists.create(this); var custom = lists.setDefaults(currentComponent); initializeTable(custom); }); var initializeTable = function(custom){ var defaults = {}; var custom = custom || {}; var query_string = $.extend(defaults, custom); var params = []; $.each(query_string, function(key,value){ params += key + ': ' + value; }) var url = custom['url']; $.ajax({ type: 'GET', url: '/' + url, data: params, dataType: 'html', error: function(){}, beforeSend: function(){}, complete: function() {}, success: function(response) { listview.html(response); } }) } $.extend($.fn, { calculation: function(){ var formReady = new Form($(this)); if(formReady.isCalculable) { formReady.initiate(); } } }) var form = $('fieldset'); form.calculation(); })(jQuery) Thanks for response. http://tinyurl.com/bw2y3sr This is my site and I want to create a Yes and No dialogue box when user closes a browser so this popup confirm dialogue should appear. Can anyone help me? Hi, I have php script that uploads a file. once i click upload it should display a animated GIF image or "Loading please wait" message with the backround transparent screen covering the whole page so that the user is not able to click anything during file upload. How can i do this? Could someone help me on this. Thanks in advance. Hi there, I would like to validate the email address typed into the prompt message by the user, but to no avail. Can some kind soul help? Code: function addOption() { var new = prompt("Enter New Item:"); if (!new == "") { var answer = confirm ("Are you sure you want to add? ") if (answer)//if answer is true { var lst = document.getElementById('lstBx'); // listbox control id // Now we need to create a new 'option' tag to add to MyListbox for (var i = 0; i < lst.options.length; i++) { arrTexts = lst.options[i].text; if (arrTexts.toLowerCase() == newItem.toLowerCase()) { alert ("That email address is already included in the list - please enter another one."); break; } else { validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i; strEmail = lst.value; // search email text for regular exp matches if (strEmail.search(validRegExp) == -1) { alert('A valid e-mail address is required.\nPlease retry.'); return false; } var optionNew = document.createElement("option"); optionNew.value = new; // The value that this option will have optionNew.innerHTML = new; // The displayed text inside of the <option> tags // Finally, add the new option to the listbox lst.appendChild(optionNew); //sort items in listbox in alpha order arrTexts = new Array(); for(i=0; i<lst.length; i++) { arrTexts[i] = lst.options[i].text; } arrTexts.sort(); for(i=0; i<lst.length; i++) { lst.options[i].text = arrTexts[i]; lst.options[i].value = arrTexts[i]; } } return false; } } } else { if(new == "") { alert("Key something to textbox please."); } else alert("Cancelled."); } } Code: <select id="lstBx" name="listBox" size="6" style="width: 580px;"> <option>a@hotmail.com</option> <option>b@hotmail.com</option> <option>c@yahoo.com</option> <option>d@gmail.com</option> <option>e@ymail.com</option> <option>f@msn.com</option> </select> An application under development has a set of core functions that carry out common tasks and a 'machine' that animates panels of lists of names and menus and provides another panel for action calls. (see attached pic). Selection of a name identifies object(s) to be worked on and menu couplets like "Name+Edit" call devices (each in a separate js file). Each js file replaces any files in the deviceScript holder in the hta file. I used to use eval(couplet+"Start")() to initiate the device, but having read about the evils of eval it dawned on me that it was unnecessary and just gave each device a start() function ... and also an optional refresh(), and compulsory finish() to pick up results and clean up. This seems to work well on my machine. The hta is intended to run locally picking up json type data and devices locally and via the net and I am concerned that importing js files is just as evil, but isn't it just like opening a web page? Any guidance really appreciated. Chris Hi every one i need ActiveX for my company web site and it work like this i will have .cab file and inside it .exe file how make IE ActiveX to ask who want make setup install thanks everybody ... I have an application written in JS and using Activex. this code work fine in IE7, IE8 but in IE9 it does not invoke the ActiveX put_EventInputString function <script type="text/vbscript" language="vbscript" for="CLSID:XXXX" event="GetParameterValue(byval TheValue)">me.EventInputString = me.getVarValue(TheValue);</script> any ideas? I have written JS , in which I used activex control which does not work on mozila , anyone has idea to to same thing without activex , here is code which just upload the textfile contains on html page . <html> <head> <script type="text/javascript" language="javascript"> function Read() { var Scr = new ActiveXObject("Scripting.FileSystemObject"); var CTF = Scr .OpenTextFile("J:\\Users\\Karimkhan\\Desktop\\2011-03-01.txt", 1, true); data = CTF .ReadAll(); document.write("<pre>" + data + "<pre>"); //alert(data); CTF .Close(); } </script> </head> <body onLoad="Read()"> </body> </html> I posted my ActiveX question in HTML but have received no replies so I was wondering if this was the thread to post it in.
Hi, I am currently detecting for Shockwave within IE by doing the following: Code: var isInstalled = false; if (window.ActiveXObject) { var control = null; try { control = new ActiveXObject('SWCtl.SWCtl'); } catch (e) { return; } if (control) { isInstalled = true; } } This works as expected and if it fails to detect Shockwave I tell the user to install Shockwave. The problem comes when AcitveX is disabled as it still returns the same message that it's not installed. I would prefer to be able to include an extra step to detect if ActiveX is disabled, in which case I can tell the user to enable it rather than giving them false advice. My only idea would be to detect for an ActiveX Object that every IE user should have installed. Any ideas on what that ActiveX Object could be or any ideas on how I could tackle this problem are greatly appreciated. Thanks Hi Chaps, I have JavaScript code, that exports a HTML table to MS Excel. This works fine on my development (local) server, however, it fails to work on my 'live' IIS server. Once I click on the Export link, I confirm the "Export to Microsoft Excel?" message, then nothing happens. I am not sure if MS Excel needs to be installed on the server or not? If anyone has any ideas, I'd be most grateful: Code: <script language="javascript" type="text/javascript"> function ExportToExcel() { input_box=confirm("Export to Microsoft Excel?"); if (input_box==true) { var xlApp = new ActiveXObject("Excel.Application"); // Silent-mode: xlApp.Visible = true; xlApp.DisplayAlerts = false; var xlBook = xlApp.Workbooks.Add(); xlBook.worksheets("Sheet1").activate; var XlSheet = xlBook.activeSheet; XlSheet.Name="Report"; // Store the sheet header names in an array var rows = tblrepeat.getElementsByTagName("tr"); var columns = tblrepeat.getElementsByTagName("th"); var data = tblrepeat.getElementsByTagName("td"); // Set Excel Column Headers and formatting from array for(i=0;i<columns.length;i++){ XlSheet.cells(2).value= "Projects - All"; XlSheet.cells(3,i+1).value= columns[i].innerText; //XlSheetHeader[i]; XlSheet.cells(3,i+1).font.color="6"; XlSheet.cells(3,i+1).font.bold="true"; XlSheet.cells(3,i+1).interior.colorindex="37"; XlSheet.Range("A1:B1000").HorizontalAlignment = -4131; } //run over the dynamic result table and pull out the values and insert into corresponding Excel cells var d = 0; for (r=4;r<rows.length+3;r++) { // start at row 2 as we've added in headers - so also add in another row! for (c=1;c<columns.length+1;c++) { XlSheet.cells(r,c).value = data[d].innerText; d = d + 1; } } //autofit the columns XlSheet.columns.autofit; // Make visible: xlApp.visible = true; xlApp.DisplayAlerts = true; CollectGarbage(); //xlApp.Quit(); } } </script> I have a program written in Javascript (saved as an HTML file that I run from my desktop by launching it in IE) which works fine on my system. Running IE 8 in Vista on one system and XP on another. When I launch the file, I get warning in the information bar: "To help protect your security, Internet Explorer has restricted this webpage from running scripts or ActiveX cntrols that could access your computer. Click here for optons..." I actually WANT this warning. When I click through it to accept, the program works fine. But about half of the people that I share this program with are not getting this warning, and it appears that the javascript never runs. At first I thought it was something in Windows 7, because two of the users were running on that OS, and I've found a number of issues described online about having problems running scripts in IE8/Win7. But the latest user is also running Vista, like me. His security settings are set to the default, Medium-High. But he's still not getting the script/ActiveX warning in the message bar. Anyone know how we can enable that warning? Thanks! Hi, Is there any way to use the activeX to execute a local aplication with parameters... Example: PHP Code: <script> var ws = new ActiveXObject("WScript.Shell"); ws.Exec("c:\\windows\\notepad.exe"); </script> Hi Chaps, I have some Javascript code, that sucessfully exports Project data from an HTML table to an Excel SpreadSheet: Code: function ExportToExcel() { var xlApp = new ActiveXObject("Excel.Application"); // Silent-mode: xlApp.Visible = true; xlApp.DisplayAlerts = false; var xlBook = xlApp.Workbooks.Add(); xlBook.worksheets("Sheet1").activate; var XlSheet = xlBook.activeSheet; XlSheet.Name="Project Details"; // Store the sheet header names in an array var rows = tbldisplay.getElementsByTagName("tr"); var columns = tbldisplay.getElementsByTagName("th"); var data = tbldisplay.getElementsByTagName("td"); //run over the dynamic result table and pull out the values and insert into corresponding Excel cells var d = 0; for (r=4;r<rows.length+3;r++) { // start at row 2 as we've added in headers - so also add in another row! for (c=1;c<columns.length+1;c++) { XlSheet.cells(r,c).value = data[d].innerText; d = d + 1; } } //autofit the columns XlSheet.columns.autofit; // Make visible: xlApp.visible = true; xlApp.DisplayAlerts = true; CollectGarbage(); //xlApp.Quit(); } As you can see, a new workbook is created and the data is exported to Excel ("Sheet1"). What I want to do is as soon as this export is complete, redirect to a seperate page, where the Jobs (linked to the Project) details are exported to Excel ("Sheet2"), without creating a new workbook. Is this do-able? Hi All, Need some urgent. We are having a javascript which is throwing the foll error "Object doesn't support this property or method". The javascript function being called is using a Scanner API. So this is using some ActiveX. Below is the code for javascript <script language="javascript"> // Initialize scanning function OnLoad() { try { Scanner.OpenScanner(); // Scanner.ScanPriority = 0; // Set scanner to Foreground Read mode before enable scanning // Scanner.EnableScanning(1); document.forms["mobileform"]["rm07m-bwartwe[1]"].value = "101"; } catch (e) { alert(e.message); } } // Clean up function OnUnload() { Scanner.CloseScanner(); // Calling Dispose is necessary for Pocket IE because of a Microsoft issue related to releasing object. if (navigator.appName == "Microsoft Pocket Internet Explorer") Scanner.Dispose(); } // Scan through soft trigger function Scan() { try { Scanner.SetSoftTrigger(1); } catch (e) { alert(e.message); } } //User-defined function to format error codes. //VBScript has a Hex() function but JScript does not. function hex(nmb) { if (nmb > 0) return nmb.toString(16); else return (nmb + 0x100000000).toString(16); } </script> There is a object tag in html <object id="Scanner"></object> The javascript functions are called from body tag. Can someone please provide some help. Thanks, Nikhil Hi Chaps, I have a Javascript ActiveX function that exports the contents of an HTML table into MS Excel. The script works fine, however, some of the dates have changed from dd/mm/yyyy to mm/dd/yyyy. I do not know why this is happening, especially as it's only to a few. Here is the code: Code: <script language="javascript" type="text/javascript"> function ExportToExcel() { input_box=confirm("Export to Microsoft Excel?"); if (input_box==true) { var xlApp = new ActiveXObject("Excel.Application"); // Silent-mode: xlApp.Visible = true; xlApp.DisplayAlerts = false; var xlBook = xlApp.Workbooks.Add(); xlBook.worksheets("Sheet1").activate; var XlSheet = xlBook.activeSheet; XlSheet.Name="Report"; // Store the sheet header names in an array var rows = tblreport_work.getElementsByTagName("tr"); var columns = tblreport_work.getElementsByTagName("th"); var data = tblreport_work.getElementsByTagName("td"); // Set Excel Column Headers and formatting from array for(i=0;i<columns.length;i++){ XlSheet.cells(1).value= "Projects - Open"; XlSheet.cells(3,i+1).value= columns[i].innerText; //XlSheetHeader[i]; XlSheet.cells(3,i+1).font.color="6"; XlSheet.cells(3,i+1).font.bold="true"; XlSheet.cells(3,i+1).interior.colorindex="37"; XlSheet.Range("B1:F1000").HorizontalAlignment = -4108; XlSheet.Range("H1:H1000").HorizontalAlignment = -4108; XlSheet.Range("J1:J1000").HorizontalAlignment = -4108; } //run over the dynamic result table and pull out the values and insert into corresponding Excel cells var d = 0; for (r=4;r<rows.length+3;r++) { // start at row 2 as we've added in headers - so also add in another row! for (c=1;c<columns.length+1;c++) { XlSheet.cells(r,c).value = data[d].innerText; d = d + 1; } } //autofit the columns XlSheet.columns.autofit; // Make visible: xlApp.visible = true; xlApp.DisplayAlerts = true; CollectGarbage(); //xlApp.Quit(); } } </script> Date Columns: F,G,I If anyone has some ideas on how to correct this, I'd be most grateful! Hi I have developed an internet mapping site which uses an html viewer with various frames to pull in a mapping window, a legend / key and a frame of tools amongst other things. It works absolutely fine in Internet Explorer version 6, but whilst testing it in Internet Explorer 7, my mapping window is not loading up the image. It might seem strange me posting this in a javascript forum but as the error is javascript related I thought I would give it a shot! The error message I am receiving is "Access is denied". After looking online, it appears as though this error could be linked to the use of frames; and those frames trying to access other windows with different document domains?? Does anyone know if new security measures have been implemented in IE7 which restricts the use of frames? My code is below; does anyone notice anything that might give this kind of javascript error? Any help will be greatly appreciated as I do not tend to dable too much in javascript! Code: <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <TITLE>Intranet GIS Service</TITLE> <HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript" SRC="javascript/aimsResource.js" TYPE="text/javascript"></SCRIPT> <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript"> // Designer will set the next variable - theTitle //var theTitle = "Intranet GIS"; var theTitle = ""; if (theTitle.indexOf("###TITLE##")!=-1) theTitle = titleList[0]; var cmdString = document.location.search; var webParams = cmdString; var reloadTimer=0; document.writeln("<TITLE>" + theTitle + "</TITLE>"); function doIt() { MapFrame.useJava=false; MapFrame.checkParams(); } function replacePlus(inText) { var re = /\+/g; inText = inText.replace(re," "); return inText; } function reloadApp() { //window.clearTimeout(reloadTimer); //reloadTimer = window.setTimeout("document.location.href = 'viewer.jsp' + cmdString",1000); //Above code replaced with this. Only the map should refresh after a resize, otherwise //all added datashare layers are lost. MapFrame.mWidth = MapFrame.getMapWidth(); MapFrame.mHeight = MapFrame.getMapHeight(); MapFrame.sWidth = screen.width; MapFrame.sHeight = screen.height; MapFrame.loadBannerLeft = parseInt((MapFrame.mWidth - 119)/2); MapFrame.loadBannerTop = parseInt((MapFrame.mHeight - 72)/2); MapFrame.document.getElementById("theMap").style.width = MapFrame.sWidth; MapFrame.document.getElementById("theMap").style.height = MapFrame.sWidth; MapFrame.iWidth = MapFrame.mWidth; MapFrame.iHeight = MapFrame.mHeight; MapFrame.legHeight = MapFrame.iHeight - 160; var cmd = 'MapFrame.sendMapXML();'; cmd += 'MapFrame.document.getElementById("theImage").style.width = MapFrame.mWidth;'; cmd += 'MapFrame.document.getElementById("theImage").style.height = MapFrame.mHeight;'; window.clearTimeout(reloadTimer); reloadTimer = window.setTimeout(cmd,1000); } </SCRIPT> </HEAD> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> var browser = navigator.appName; var moreStuff = 'onresize="reloadApp()"'; var addNS = 0; if (browser=="Netscape") { addNS = 3; } document.writeln('<FRAMESET ROWS="' + (45+addNS) + ',*,30,0" FRAMEBORDER="No" FRAMESPACING="0" onload="doIt()" BORDER=2 ' + moreStuff + '>'); document.writeln('<FRAME NAME="TopFrame" SRC="topbar.htm" MARGINWIDTH="5" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" NORESIZE>'); document.writeln('<FRAMESET COLS="' + (30+addNS) + ',*,270" FRAMEBORDER="No" FRAMESPACING="0" BORDER="2">'); </SCRIPT> <FRAME NAME="TextFrame" SRC="text.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" NORESIZE FRAMESPACING="0" BORDER="2"> <!-- If textframe is used--> <FRAMESET ROWS="*,115"> <FRAME NAME="MapFrame" SRC="MapFrame.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="Yes" RESIZE="YES"> <FRAME NAME="ToolFrame" SRC="blank.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="Auto" FRAMEBORDER="No" RESIZE="YES"> </FRAMESET> <!-- If textframe is not used --> <!--<FRAME NAME="MapFrame" SRC="MapFrame.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" RESIZE="YES">--> <FRAME NAME="TOCFrame" SRC="TOCFrame.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="Auto" FRAMEBORDER="No" RESIZE="YES"> </FRAMESET> <FRAMESET COLS="400,*" FRAMEBORDER="Yes" BORDER=2 FRAMESPACING="0"> <FRAME NAME="ModeFrame" SRC="bottom.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" NORESIZE> <FRAME NAME="ModeFrame" SRC="bottom.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" NORESIZE> </FRAMESET> <FRAME NAME="PostFrame" SRC="jsForm.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" NORESIZE FRAMESPACING="0" BORDER="2"> </FRAMESET> <NOFRAMES> <BODY> <P> </BODY> </NOFRAMES> </HTML> Hi all new guy on the block here, I've got a website, and I want to add a welcoming message which hovers on a certain part of the page which only loads for the visitor for the first time they login, and won't again(presumably cookies used). And says something like "adjust your settings here.." I don't want it to be an external popup but something that loads on the page in a certain area, defined by me (PX-pixle reference) I think i nutted something out in a bit of PHP, this is what i've got so far PHP Code: <?php if (firstLogin()){ genSpecial(***load jquerie or css etc***); } else{ genRegular(); } ?> can anyone help me figure out how to make this all work and load a box from jquerie or something similar? thanks David I was wondering if there was an easy way to configure a message box to resemble that of a login form. It would preferably have two text fields for username/password and OK and Cancel buttons as well. I currently have a normal login form on my website designed using PHP but it does not figure into what we need to do now. I'm not sure about going about this and I have tried looking for quite sometime for an example of this but cannot find one.
|