html >> unable to execute a javascript in a dynamically generated HTML

by vickrish » Thu, 05 Jan 2006 16:38:16 GMT

Hi,


I have a dynamically generated HTML code rendered on a browser instance

created though code (AxSHDocVw.AxWebBrowser instance) . I have used a
javascript to generate a print preview.


function printPreview () {
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0
CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';


document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(7, 1);



}


But when I try to execute this script on the click of a button , I get
the following error:

"An Activex Control on this page is not safe."
Your current security settings prohibit running unsafe controls on this

page.


I do not have any option to modify the security settings as the browser

instance what I have is instantiated through code
(AxSHDocVw.AxWebBrowser object)


Also, when I use the same HTML code and save it on the disk and then
open the file, the Javascript executes without any problems.


Can anyone provide a solution as to how I can prevent this error and
execute the script successfully ?



Similar Threads

1. dynamically generating html vs using html scaffolding?

Are there any guidelines people use that help them decide when it is
better to dynamically generate all html elements using javascript
versus actually writing some html and using it as scaffolding?
I have been using the extjs framework ( I haven't see this library
critiqued much on this forum - unlike prototype, jquery and dojo which
the regulars here tend to eviscerate - unless i've missed some
threads, which is quite possible) and it allows both mechanisms for
all its widgets and layouts.   But i'm not sure what the pros and cons
are to either approach.  Obviously if you don't have access to the
html page then your options are limited.

Anyway, I was planning on posting this within the extjs forums (and I
still might if it doesn't spark much of a response here), but then
thought that this was more of a general javascript/style question and
so have posted this here.

Would really appreciate your thoughts.

Thanks,
Faisal Vali, MD, MSc
Loyola Radiation Oncology
Chicago, IL


2. Avoid sending GIF files, while dynamically generating HTML pages

3. HTML and Javascript generated from CGI script fails when generated

4. ASP and dynamically generated HTML - Adobe Dreamweaver

5. Dynamically generated controls (Javascript) not posting values to server

I've a very strange issue here. I've this JS code:

var hidden = document.createElement('input')
//hidden.type='hidden';
hidden.value = getIdForUser(userTag)
$('assignedUsersInputs').appendChild(hidden);
var i =0;
for(var node = $('assignedUsersInputs').firstChild;node !=null; node =
node.nextSibling)
{
  if(node.nodeType != 1) //input
	continue;
  node.id = 'project.Users['+i+'].Id';
  i++;
}

I use it to create a couple of inputs, and then I post to the server,
but the server side can't see those controls.
When I do request.Params.AllKeys, I can't see those values there, but
they exists (enabled, btw) on the client.
This behavior is consistent in both IE and FF, so I think this is
something that I'm doing wrong.
Any ideas?

6. Dynamically generating Javascript - Asp.Net

7. Javascript in dynamically generated window

8. Dynamically generate textboxes using javascript