codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Waiting to load a page object after the page loads  Archive Import (Pete Ruby) at 14:32 on Tuesday, August 05, 2003
 

Haver a page w/ an ActiveX object that i want to load at the end of the page load, ie, load all of my ASP page, then load the ActiveX object. Any ideas?

Pete

  Re: Waiting to load a page object after the page loads  Troy Wolf at 15:29 on Tuesday, August 05, 2003
 

Here`s one method.

Create a page with nothing but the ActiveX object. Then in your main page, create a hidden IFRAME. Use the window.onload event to load the object source page into the IFRAME after your main page has loaded.

Sample code to demonstrate this technique. This example uses the printing control from www.meadroid.com. This is cool object that lets you strip the default browser header and footer when you print from your web applications.

First, create a page with just the object. Call this MyActiveX.html:
-----------------------------------

<object id="factory" style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="http://www.meadroid.com/scriptx/ScriptX.cab#Version=6,1,429,14" VIEWASTEXT>
</object>

-----------------------------------

Second, create the main page. This will contain the hidden IFRAME and wait until page load completes, then load the object src into the IFRAME. Name this page MyPage.html:
-----------------------------------

<script language="javascript1.2">
function DoPrint() {
self.focus();
//save existing user`s info
var factory = objectFrame.factory;
var h = factory.printing.header;
var f = factory.printing.footer;
//set header and footer to blank
factory.printing.header = "";
factory.printing.footer = "";
//print page with normal Windows print prompt
factory.DoPrint(true);
//restore user`s info
factory.printing.header = h;
factory.printing.footer = f;
}
function LoadTrigger() {
objectFrame.location = "MyActiveX.html";
}
window.onload = LoadTrigger;
</script>
<IFRAME name="objectFrame" width="0" height="0" src=""></IFRAME>
Clicking the Print button will call a javascript function that references
an ActiveX object from another window. That window happens to be a hidden IFRAME within
this page. The source of the IFRAME is not loaded until this page has finished loading.
This is handled by the window.onload event. View the source.
<p>
<input type="button" style="font-size:8pt;" value="Print" onclick="DoPrint()">

-----------------------------------

That should do it for you. Of course I suppose there may be special things in how a particular ActiveX object works that may cause issues with my method--anything is possible, eh?!
Troy Wolf: site expert
SnippetEdit Website Editor


  Re: Waiting to load a page object after the page loads  Elain at 00:48 on Thursday, February 17, 2011
 

Your method is so cool, thanks for your wonderful sharing!
______________________________
logo maker|flash banner|javascript menu








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  sending of file over network
•  project on networking
•  Re: onclick thumbnail images in gridview or datalist
•  Re: C++ Beginner question
•  Re: Adding controls to the page in Page_Load event
•  Re: drop-down menu selected value
•  issue with onunlaod event in Firefox
•  Re: Stored procedure do not return recordset
•  Re: how to close w3wp.exe dialog Box programmatically ?


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2011