How do you suppress script errors in HTAs? - vbscript

I have an HTA that loads up an external webpage inside a nested IFRAME. This webpage (which I don't have control over) throws an "Access Denied" error in my HTA asking the user if they "want to continue running scripts on this page". What I want to do is have my HTA suppress all scripting error messages regardless of where they originate
Here's a very basic idea of how my setup is working:
<html>
<head><HTA:APPLICATION ... ... </head>
<body>
...
<div id="navigation">...</div>
<div id="browsers">
<iframe APPLICATION="yes" src="http://myserver/browse.php?src=http://www.example.com/">
<!-- contents of http://myserver/browse.php?src=http://www.example.com/ -->
<html>...
<body>
<div id="titlebar">...</div>
<iframe APPLICATION="no" src="http://www.example.com/">
<!-- contents of http://www.example.com/ with js that causes error -->
</iframe>
</body>
</html>
</iframe>
<iframe APPICATION="yes" src="http://myserver/browse.php?src=somethingelese"></iframe>
</div>
</body>
</html>
And here is a screenshot of the error:

As far as I know there isn't a way to suppress errors like that. If you have access to their registry or group policy here is the relevant Registry Value (for IE naturally) that disables that popup:
Key: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
Name: Disable Script Debugger
Type: REG_SZ
Value: no

A sentinent GetWindowText() -> SendMessage WM_CLOSE based dialog closer could deal with that but is not exactly disabling
I've been searching for days and haven't found solid solution - perhaps HTAs do not serve their simplistic rationale after all, at least when using actual browser info
By the way changing the IE8 script debugger does not disable the error message - it merely disables the debug dialog and replaces it with a script error
Unchecking the IE flag "Error Dlg Displayed On Every Error" does not alleviate the issue either

Related

Master page throws error when code is inserted

I have a master page that throws an error on content pages when the following line of code is inserted into the master page. It will not let me enter design mode.
<script src='<%= CacheHelper.Fingerprint("/assets/scripts/app.min.js") %>' />
However, the following line of code doesn't throw an error. I've tweaked the quotes, added a type etc, but it still refuses to play ball.
<link rel="stylesheet" href='<%= CacheHelper.Fingerprint("/assets/styles/app.min.css") %>' />
I'm using VS2010.
After trawling, trying and testing for a few hours I can categorically say that 99% of the answers to similar questions do not work.
The answer I found that did work was to replace the end tag '/> with '></script>' - after this Visual Studio started behaving.

Ace editor "SECURITY_ERR: DOM Exception 18" in Chrome when running locally (no server)

I'm trying to run Ace editor from file system for now and in Chrome I'm getting:
"SECURITY_ERR: DOM Exception 18"
FireFox doesn't mind it.
Found this on google groups:
due to same origin restrictions workers can't be loaded from cdn you
need to put them on your site, and add ace.config.set("workerPath",
"path/to/ace/src-min");
No joy.
I'm initializing the editor like so:
<script src="js/source-editor/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
ace.config.set( "workerPath", "js/source-editor/src-min-noconflict");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/css");
</script>
Am I missing something hopelessly simple?
This isn't a full solution but it may help:
editor.getSession().setUseWorker(false);
This turns off worker, probably destroying performance in the process. It should probably be conditional on whether you are a local file by checking the url.
For what's it worth, issue disappears one deployed to server.

Testing a method that implements IHttpHandler.ProcessRequest

So I have a method that implements IHttpHandler.ProcessRequest. It accepts an HttpContext parameter. This parameter is just a form that is filled out with some XML. Here is the HTML that I am using to generate the post context:
<html>
<body>
<form name="form1" method="post" action="http://localhost:7703/api.ashx">
<textarea name="XML" id="XML" rows="25" cols="100"></textarea>
<br/>
<input type="submit" value="submit"/>
</form>
</body>
</html>
As you can see, very simple. This is just used for testing purposes. What I am doing is posting XML in that textbox, and hitting submit. However, I am not sure what to attach my visual studio project to in order to debug. I try attaching it to w3wp.exe like I do when I test the app in a browser and stuff, but that doesn't seem to be working. It still says "This breakpoint will never be hit, no symbols loaded..." blah blah blah, when I put a breakpoint next to the ProcessRequest method and attach.
How do I test this properly?
Thanks guys.
If you run this locally you should be able to "run" it from within Visual Studio and VS will automatically attach it self to the correct process.
If I attach to the development server at the same port as the post, it works! :)

Simple ajax/prototype problem

im beginning with Ajax, i have problem with including Ajax files.
Ajax code written in original page (like index.php) and placed in (head) section works fine, but when i try to place code in external file (in js folder, where is placed prototype.js file), i don't get any response, not even in Firefox Error Console.
I haven't changed Ajax code except url for calling PHP function.
edit:
calling ajax files:
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/myValidation.js"></script>
</head><body>
....
Username: <input type="text" name="uname" id='uname' />
Available?
<span id="result"></span>
Email address: <input type="text" name="email" />
...
I embaded this function call in html. Validate function is from book "PHP and Script.aculo.us Web 2.0 app interfaces"
myValidation.js
function Validate(){
var user=$('uname');
var name="uname="+user.value;
var pars=name;
new Ajax.Request(
'myValidation.php',
{
method:'post', parameters:pars, asynchronous:true, onComplete: showAvailable
}
);
}
function showAvailable(originalRequest){
var newData=originalRequest.responseText;
$('result').innerHTML=newData;
}
This example is from mentioned book
You haven't shown us your myValidation.js file, but here are the typical reasons I see when people move from inline script blocks to external files and things stop working:
They put script blocks in the external JavaScript files. You probably didn't do that, but I've seen it often enough to mention it. Your external script is pure JavaScript, so for instance it should be:
function Validate() {
// ...
}
not:
<script type='text/javascript'>
function Validate() {
// ...
}
</script>
I've seen the latter a fair bit.
They put the JavaScript file in a location that doesn't match their script tag src.
They left an opening <!-- or closing --> in the script. Important not to do that, in external JavaScript files those are syntax errors.
They're using a web server that's case sensitive and the src attribute and the file's actual name don't match.
They're using a web server sensitive to permissions and the file doesn't have the right permissions.
In the case of the last two above, it's easy to check: Just open a new tab and actually enter the URL of the JavaScript file. If you see the JavaScript, great; if not, you probably have more information.
For issues like this (and hundreds of others), there's nothing like having a decent toolset. For debugging JavaScript on browsers, there are quite a few. There's Firebug (a Firefox add-in), Chrome's and Safari's Development Tools (built into the browsers), Microsoft Visual Studio or Script Debugger for debugging with IE, etc. Firebug and Dev Tools would both tell you about broken src links, as well as any exceptions, etc.
Have you checked that those files are accessible from the HTML code? And more - have you placed you scripts in the bottom of the page - because AJAX will bind it's handlers only to existing elements?
Problem solved.
In /js/ folder i had one php file, that i put there just because of simplicity. After moving it to other location all worked. Don't know if that is rule, nut no php files in /js/ folder. Thanks T.J and Tomasz

Internet Explorer Error

The main error shown in IE is : ' Could not complete the operation due to error 80020101.'
The error is displayed when the ExtJS framework tries to load a page containing a Ext grid component through an ajax request.
It works without problems in Firefox and Chrome.
Another error which is shown by IE is 'Expected identifier, string or number' which points to the line containing HTML inline style definition which is perfectly valid. I am not sure why this error is shown. I feel IE is pointing this error to the wrong place.
Could anyone please help me out on this?
"Could not complete the operation" errors in IE are usually caused by trying to modify the DOM before it is ready.
Move the JS so it fires in (for example) the onload event, or a JS library's ondomready event.
If you are loading a page using ajax and it has a inline script file like below add // before
the open comment tag
<script type="text/javascript">
// <!--
alert('text');
// -->
</script>
http://dracoblue.net/dev/could-not-complete-the-operation-due-to-error-80020101/137/

Resources