|
HTML Object |
Top Previous Next |
|
this dependency on IE is a disadvantage, however, the below advantages of using IE core library outweigh this small disadvantage...
MMB specific issues:
MMB Html Object can insert ready made buttons for you if you need them and you are in hurry. See the Html Object command description.
Hide Border and Always Hide Vertical Scroll Bar You can Hide the border of the control and eventually hide the vertical scrollbar. This way you can display HTML file in your MMB project without disturbing the look of your application.
Tip 1: You can use a special links in your HTML files to tell the MMB player to go to other MMB page or run script.
Use the page name to move to a specific project page. <a href="page:Page 2">Go To Page 2</a>
To jump to first, next, last page or back to previous page (in page history), use these four keywords -first, next, last and back. <a href="page:next">Go To Page 2</a>
To run a specific Script object from current page: <a href="script:Script1"> Run Script1</a>
To run a specific Script object from another page: <a href="script:Page 2::Script1"> Run Script1</a> From 4.9.8 there is a new exciting option to run the MMB script from HTML/JavaScript code! This open whole new world of option, because now you can not only run the MMB scripts from MMB but you can also send the variables from HTML/JavaScript to MMB or even call the MMB scripts after a specific action/event in JavaScript code! To run the MMB code from HTML code (in MMB Browser) use the following syntax: Loud script parsing - in case of error in MMB script, you will receive a message box with script error: Quite script parsing - in case of error in MMB script, no error will be generated. Be careful about using this option! ..where " is an "escape" sequence replacing the " (double quote) character. The double quote written in escape sequence is then taken as a text and not as part of HTML code. For some more HTML "escape" character, see this page: In cases you wish to pass more than just one MMB parameter on single link click, you can do this by adding %0D%0A (Carriage Return + Line Feed) sequence. The code should then look like that: <a href="scriptcode1:HTMLVar$='MMB Variable from HTML' %0D%0A LoadText("Text1","HTMLVar$")">Fill MMB Variable and show MessageBox</a>
As mentioned before, the scriptcode can not only be run from HTML but also from JavaScript code! Say "Good Bye!" to all nasty tricks (like using clipboard) to pass the JavaScript variables to MMB! The syntax of calling scriptcode from JavaScript is a bit messy, but it's not that complicated as it may look ;)
The basic rule is that each quote and double quote used by MMB script must be started with backslash character. So instead of using just " (double quote) you have to use \" (backslash + double quote). Although the JavaScript code with MMB code sequences may look strange, it's probably much easier to read and understand than the HTML escape sequences.
Here is a sample passing the JavaScript string variable to MMB variable:
// this is just a JavaScript string variable JavaVar='HelloWorld'; // this passes the JavaScript variable to MMB window.location.href= 'scriptcode1:test$='\''+JavaVar+'\''; ...where the red marked parts are MMB parts of code. The rest of text is just JavaScript syntax.
Description of individual parts of code: window.location.href is a JavaScript equivalent of <a href="url">link</a> action in HTML.
scriptcode1: calls the MMB script from Browser object.
test$='\''+JavaVar+'\'' is just a combination of MMB RunScriptCode command, JavaScript JavaVar variable and some backslashes ;)
After calling the above mess of quotes and backslashes, the MMB project will receive this: test$='HelloWorld'
And as in case of HTML, if you wish to run more than just one MMB script line, you need to use the previously described %0D%0A (Carriage Return + Line Feed) escape sequence.
// this reads text from HTML form input: var InputText = document.form1.formtext1.value + ''; // this line of code fills the MMB variable with above obtained variable, load the variable in MMB Text1 object, Refresh the screen and finally show the MMB Message box. window.location.href='scriptcode1:Input$=\''+InputText+'\' %0D%0A LoadText(\"Text1\",\"Input$\") %0D%0A Refresh(\"\") %0D%0A Message(\"This message is created from JavaScript\",\"HTML Input: ' +InputText+ '\")';
All the above HTML/JavaScript tricks can be seen in the html_mmbscript.mbd project. Tip 2 You can use Embedded html files. If you use it don't forget that you have to embed all the images and related pages your html file use or link to. Embedded files can't be in different directories so all html files and images must be in the same directory. !!! A better solution than just using the htm/html files with separate linked Images seems to be an IE option to save the entire HTML page with all images or flash movies into a single "Web Archive" (mht) file. In IE you can save entire HTML page into a single MHT file via menu File..SaveAs. Then just embed that web archive file into your project or leave it external, if the file is too big for embedding. Then you can load that web archive via HTML properties (in a design time) or via Browser script function. Note: Browser Object needs IE 4.x-5.x installed on users machine. If user doesn't have IE, then the object will launch default html viewer. LIMITATION! The TAB key to jump between the HTML form fields cannot be used in MMB HTML object. It's because the HTML object is just an ActiveX object insert in MMB project (parent) window. At the moment, we have no solution to this issue. |