Source language: Translate to:

Two browser Questions !!

Questions and information about creating Internet aware NeoBook applications. Including PHP, HTML, FTP, HTTP, Email, etc.

Moderator: Neosoft Support

Postby Neosoft Support » Mon Oct 18, 2010 10:55 am

Can i change the Id of the browser so that the website that i am browsing is seeing my browser not as Internet explorer but some other name i can change it to ?


No, I don't think that's possible.

Can i disable the browser component until the web page has completely loaded ? and while the component is disabled ? display a progress bar over the page ?


You can try using the browser object's "Before Navigate" and "Navigate Complete" actions to disable and enable the browser. For example:

Before Navigate:

DisableObject "WebBrowser1"

Navigate Complete:

EnableObject "WebBrowser1"

There's no way to know in advance exactly how long it will take to load a particular web page. Most browsers display a simulation of a progress bar and basically guess about how long it will take to download the page. You could create your own animation or turn on the browser object's "status bar" which includes its own simulated progress bar.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby Tony Kroos » Sat Nov 06, 2010 5:47 am

3rd question: when I load webpage to neobook browser object and click on the link that opens in a new window, it opens in IE system browser, not in neobook object. It may be "a href=... target=_blank" link or javascript construction (click events and so on). How to force any links to be opened only in neobook webbrowser object?
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Postby dpayer » Mon Nov 08, 2010 5:04 am

Tony Kroos wrote:3rd question: when I load webpage to neobook browser object and click on the link that opens in a new window, it opens in IE system browser, not in neobook object. It may be "a href=... target=_blank" link or javascript construction (click events and so on). How to force any links to be opened only in neobook webbrowser object?


Remember, the browser object simply embeds IE into NB. If the HTML instructs IE to open a new browser window, it will and it will not be embedded in NB. But, using NB script you could actively rewrite all HREFs in the downloaded to have a target = _top to keep it in the object. This may have an impact on what the page does though. Example, you may lose your navigation links. You would also have to deal with any links that reference a javascript function too. It may get a bit complicated.

David P.
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby Tony Kroos » Mon Nov 08, 2010 5:40 am

dpayer wrote:rewrite all HREFs in the downloaded to have a target = _top to keep it in the object. This may have an impact on what the page does though. Example, you may lose your navigation links. You would also have to deal with any links that reference a javascript function too. It may get a bit complicated

Thanks for your answer, I have similar thoughts... I just tried to use browser object for usual web surfing and as practice shows, it is really complicated and often spoils the page functionality... btw, when I enable "trap popup windows" option, such link opens in new nb browser window (not in IE)... ok, thanks anyway, I'll see what can be done by myself...
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Postby Tony Kroos » Wed Apr 06, 2011 11:56 am

Question about BrowserLoadFromStr and local javascript files.
I need js code source to be executed from local js-file, for ex.:

Code: Select all
<html>
  <script src="c:\test.js"></script>
...
</html>


test.js wrote:alert('Hello world');


When I load this code in WebBrowser object as local .html file it works fine. But is there any way to make it work via BrowserLoadFromStr? Now it doesn't...
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Postby Gaev » Wed Apr 06, 2011 12:56 pm

Tony Kroos:

If you are going to be using BrowserLoadFromStr ... you can always preceed this with some commands (FileRead, StrReplace) to read the contents of this Javascript file into another variable ... and then insert this content into the variable that will be associated with the BrowserLoadFromStr command ... i.e.
Code: Select all
<html>
  <script>
  {javascript file contents inserted here}
  </script>
...
</html>
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Tony Kroos » Wed Apr 06, 2011 11:04 pm

It seems that [#124] special character "|" is not working in BrowserExecString. That is why I was going to use local js.
Try to load this:
Code: Select all
<script type="text/javascript">
alert ('hello, script is running');
var str="This is not working";
var reg=/i[#124]o/g;
var result=str.replace(reg, "REPLACED");
alert(result);
</script>

No messages, no errors, just won't run...
It works only if I remove this -> [#124]o <- part of string. But this script should work in both cases.
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Postby Gaev » Thu Apr 07, 2011 5:14 am

Tony Kroos:
It seems that [#124] special character "|" is not working in BrowserExecString.

a) Use the ! character to make sure NeoBook does NOT try and do Math etc. on your content containing the |character.

b) If this does not resolve it, try and use the ASCII code for this character ... | ...
Code: Select all
var reg="/i" + "& #124;" + "o/g";
... note the space between & and # is only to prevent the Forum Software from showing it as | ... remove it in your NeoBook script.
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Tony Kroos » Thu Apr 07, 2011 6:15 am

Gaev wrote:Use the ! character

This char interpretes as ordinary html text in browser and doesnt affect on variable content. "|" is still missing.
Gaev wrote:use the ASCII code for this character

& #124; and others like that is not valid for js expressions, it is for html use only. But you gave me the clue - String.fromCharCode(124).
Code: Select all
var reg="/i"+String.fromCharCode(124)+"o/g";

But it is still doesnt work (even as local), it needs | and refuses everything...
:cry:
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Postby Tony Kroos » Thu Apr 07, 2011 6:55 am

I just can not understand one thing.. why [#124] character is not working in js/html while other does? there must be some kind of bug maybe...
Also, when I tried to run script via BrowserExecScript I got 80020101 error.
There are no such complications for special chars like [#34] or [#91][#93], they work fine.
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Postby Gaev » Thu Apr 07, 2011 9:39 am

Tony Kroos:
But it is still doesnt work (even as local), it needs | and refuses everything...
... this is what I tried in a Button object ...
Code: Select all
Setvar "[Script]" "alert ('hello, script is running');var str='This is not ' + String.fromCharCode(124) + ' working';alert(str);"
BrowserExecScript "WebBrowser11" "[Script]" "JScript"
.. and it worked just fine for me ... the second alert message was ...
This is not | working
... so I suggest you revisit the logic of your Javascript ...not sure what you are trying to do here ...
Code: Select all
var reg=/i|o/g;
var result=str.replace(reg, "REPLACED");
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Tony Kroos » Thu Apr 07, 2011 11:41 am

not sure what you are trying to do here ...

This is a sample of replacing string content based on "regular expressions", and the "|" char is often used here.
Every "i" and "o" character in str will be replaced by string "REPLACED"

So, when I construct string manually it's ok, but when it comes to replacing nothing works, result is the same string:
Code: Select all
var str='This is not working';
reg='/i'+String.fromCharCode(124)+'o/g';
alert('string is okay - '+reg);
var result=str.replace(reg, "REPLACED");
alert(result);

Compare to this (only "i" is replaced):
Code: Select all
var str='This is not working';
var reg=/i/g;
var result=str.replace(reg, "REPLACED");
alert(result);


Still I have not found a solution to use js with | characters... I'll try to rewrite js function without need to use |, or better continue researching how to use local js in browserloadfromstr... :roll:
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Postby Gaev » Thu Apr 07, 2011 1:34 pm

Tony Kroos:
continue researching how to use local js in browserloadfromstr
... in your earlier post you said that this ...
Code: Select all
<script src="c:\test.js"></script>
did not work.

Was this just a sample ... or does your file actually reside in c:\test.js ?

I ask because when you deploy BrowserLoadFromStr, the Browser does not have a Base Folder to go by ... so you have to have a <base href="...."/> tag in the <head> section of your document ... otherwise, something like src=test.js" will not work.
Still I have not found a solution to use js with | characters... I'll try to rewrite js function without need to use |,
I played around with the replace method in Javascript ... looks like the first parameter in the command is NOT a string expression ... which is why you get an error when you try to compose the Regular Expression variable with a String.fromCharCode(124) ... since I do not know the var type, I can't suggest how to compose this variable ... so it looks like you will just have to accomplish your objective using more than one such replace functions.
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Tony Kroos » Thu Apr 07, 2011 3:07 pm

Gaev wrote:looks like the first parameter in the command is NOT a string expression
Yes, it is not a 'string', but anyway I was hoping to reconstruct it manually )) And also it seems to be a reason why [#124] doesnt work.
Gaev wrote:<base href="...."/> tag
Thanks, I will keep trying... local js-file is going to be my only solution now
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Next

Return to NeoBook and the Internet

Who is online

Users browsing this forum: No registered users and 1 guest