Source language: Translate to:

tabbed browsing

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

Moderator: Neosoft Support

tabbed browsing

Postby fkapnist » Tue Dec 16, 2014 6:36 am

I added "tabbed browsing" to my Neobook web browser project.... Each tab automatically adjusts its width to fit into the toolbar.

Image

It was easy to do but rather tedious...

Image

The only problem is that the "Open in new tab" item is disabled in the right click menu... All I need is to grab the URL it would return and I can do the rest...

Image

So how do I enable that function? Is it something in the Browser_Emulation registry?

:?:
User avatar
fkapnist
 
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece

Re: tabbed browsing

Postby Neosoft Support » Tue Dec 16, 2014 12:12 pm

You might be able to customize the context menu with JavaScript. Here are some ideas:

https://www.google.com/webhp?ion=1&espv=2&ie=UTF-8#q=javascript%20modify%20context%20menu
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5602
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: tabbed browsing

Postby fkapnist » Tue Dec 16, 2014 5:56 pm

Neosoft Support wrote:You might be able to customize the context menu with JavaScript. Here are some ideas:

https://www.google.com/webhp?ion=1&espv=2&ie=UTF-8#q=javascript%20modify%20context%20menu


Thanks. I found some scripts I can use. But where would I put them? As an action when the Neobook app starts or as an action in the [WebBrowser1] object?

To enable it would I need to use :
window.external.nbExecAction( action script )


:?:
.
User avatar
fkapnist
 
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece

Re: tabbed browsing

Postby Neosoft Support » Wed Dec 17, 2014 11:44 am

You can use NeoBook's BrowserExecScript action to execute the JavaScript on the site loaded into the web browser. You can try putting this in the browser object's Navigate Complete action.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5602
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: tabbed browsing

Postby fkapnist » Fri Dec 19, 2014 10:42 am

Neosoft Support wrote:You can use NeoBook's BrowserExecScript action to execute the JavaScript on the site loaded into the web browser. You can try putting this in the browser object's Navigate Complete action.


I put this test Javascript (ContextMenu) in the function library:

Syntax: [ Download ] [ Hide ]
Using Javascript Syntax Highlighting
if (window.document.addEventListener) {
        window.document.addEventListener('contextmenu', function(e) {
            alert("You've tried to open context menu"); //here you draw your own menu
            e.preventDefault();
        }, false);
    } else {
        window.document.attachEvent('oncontextmenu', function() {
            alert("You've tried to open context menu"); //here you draw your own menu
            window.event.returnValue = false;
        });
    }
Parsed in 0.005 seconds, using GeSHi 1.0.8.10


But it did not work when called. If I use it in the Navigation Complete tab:
BrowserExecScript "WebBrowser1" "ContextMenu()" "JavaScript"

It expects to find a ContextMenu() function within the loaded web page, but I want all webpages to use my context menu.
I think a solution may be here though:

IDocHostUIHandler::ShowContextMenu

By implementing this method, you gain control over the shortcut menus displayed by the WebBrowser Control when a user right-clicks. You can prevent Internet Explorer from displaying its default menu by returning S_OK from this method. Returning some other value, like S_FALSE or E_NOTIMPL, allows Internet Explorer to go ahead with its default shortcut menu behavior.

If you return S_OK from this method and nothing more, you can prevent any right-click behavior by the WebBrowser Control. This may be all you desire in many scenarios but you can do more. Often, you use this method to create and display your own shortcut menu before returning S_OK. If you know the resources from which the WebBrowser Control displays its menus, and how it chooses them, you can also effectively customize the default WebBrowser Control shortcut menus themselves.

Refer to WebBrowser Customization (Part 2) for an implementation example of this method.


http://msdn.microsoft.com/en-us/library/ie/aa770041%28v=vs.85%29.aspx#ShowContextMenu

Handling Events in Visual Basic Applications

WebBrowser Control
How do you trap events in objects contained by WebBrowser objects in a way that enables you to handle the events with native Microsoft Visual Basic code? This article explains how to create a Visual Basic-based application that consists of a class module and a form that contains a WebBrowser object. Members of the class trap events from an HTML document object contained by the WebBrowser object, then "forward" the events to a procedure in the form. Visual Basic code in the form can then execute in response to the forwarded events.

homework to do...

Here is a small program that adds an item to the Explorer context menu:

http://www.nirsoft.net/utils/ie_design_mode.html

I only need to modify an existing item on the context menu.

I think I found some easy solutions here:

http://www.howtogeek.com/howto/windows-vista/how-to-clean-up-your-messy-windows-context-menu/

http://www.guidingtech.com/144/how-to-edit-remove-unwanted-applications-from-right-click-menu-in-windows/

http://www.downloadcrew.com/article/32015-easy_context_menu




:!:
.
User avatar
fkapnist
 
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece

Re: tabbed browsing

Postby Neosoft Support » Fri Dec 19, 2014 12:04 pm

Don't use the function library, just pass the JavaScript directly to the BrowserExecScript action. For example, this works for me:

Code: Select all
BrowserExecScript "WebBrowser1" "if (window.document.addEventListener) {|  window.document.addEventListener('contextmenu', function(e) {|    alert([#34]You've tried to open context menu[#34]); //here you draw your own menu|    e.preventDefault();|  }, false);|    } else {|   window.document.attachEvent('oncontextmenu', function() {|   alert([#34]You've tried to open context menu[#34]); //here you draw your own menu|   window.event.returnValue = false;| });|}" "JScript"
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5602
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: tabbed browsing

Postby fkapnist » Fri Dec 19, 2014 12:30 pm

You can activate tabbed browsing in the context menu of your NeoBook [WebBrowser] objects by going to this registry item. Add you application filename (DWORD) and enter value 1. The context menu will now allow "Open in new tab." However, it will open in a new window unless it can be modified or a new item maybe is added to the context menu...

Image
User avatar
fkapnist
 
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece

Re: tabbed browsing

Postby fkapnist » Fri Dec 19, 2014 12:42 pm

Neosoft Support wrote:Don't use the function library, just pass the JavaScript directly to the BrowserExecScript action. For example, this works for me:

Code: Select all
BrowserExecScript "WebBrowser1" "if (window.document.addEventListener) {|  window.document.addEventListener('contextmenu', function(e) {|    alert([#34]You've tried to open context menu[#34]); //here you draw your own menu|    e.preventDefault();|  }, false);|    } else {|   window.document.attachEvent('oncontextmenu', function() {|   alert([#34]You've tried to open context menu[#34]); //here you draw your own menu|   window.event.returnValue = false;| });|}" "JScript"


Yes, that works! But I only want to modify one item of the native context menu. Creating a brand new context menu for Explorer kind of side tracks me... this project is about "tabbed browsing." I wonder if I can just grab the URL from the native menu without letting it trigger anything...
User avatar
fkapnist
 
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece

Re: tabbed browsing

Postby fkapnist » Fri Dec 19, 2014 1:57 pm

This little freeware program is very useful.

http://rbsoft.org/downloads/right-click-enhancer

It has a graphical interface that allows you to change and add all sorts of context menus. Then check to see what changes it made to the registry and re-create them in your Neobook program.

Image



:arrow:
.
User avatar
fkapnist
 
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece

Re: tabbed browsing

Postby fkapnist » Mon Dec 22, 2014 5:00 am

It takes more than one javascript to get the context menu to open a new tab. Note that the tab system I use is not the same as the Microsoft - Delphi module. (Internet Explorer they say can open 300 tabs before crashing). I can have 20 or 30 hidden Neobook buttons that become visible and resize as "tabs," then load a corresponding web browser object. The first javascript goes in the "Navigation Complete" section of each web browser object as a "BrowserExecScript" javascript string. It does NOT prevent the default opening of the right click menu, but triggers the Neobook publication before the menu appears. It executes a subroutine "getStatus" which gets the last URL (if any) that was right-clicked upon (via the browser status) and then sets it as the variable "TabLastStatus."

---------------------------------
javascript 1
------------

Code: Select all
if (window.document.addEventListener) {

window.document.addEventListener('contextmenu', function(e) {

window.external.nbExecAction( 'GoSub "getStatus"' );

// e.preventDefault();

},

false);

} else {

window.document.attachEvent('oncontextmenu', function() {

alert("You've tried to open context menu"); //here you draw your own menu

window.event.returnValue = false;

 });

}


-------------------------------------
Neobook subroutine:
-------------

Code: Select all
:getStatus
SetVar "[TabLastStatus]" "[WebBrowser[X]Status]"
Return

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

Image

The second javascript does not go directly into the Neobook pub but is an external file accessed by the Windows registry. I used a freeware program to add the new item "Open in Neobook tab" to the IE right-click menu. (This context menu item can be automatically added to the Windows registry when the publication starts and automatically removed when the publication exits.) Clicking on "Open in Neobook tab" launches a html file that runs a tiny Neobook system tray app. The tray app identifies the Neobook parent "[theAppID]" and opens a new tab with "[TabLastStatus]" as the corresponding URL.

--------------------------------------------
javascript2 (External HTML)
---------


Code: Select all
<html>
<head>
    <title>Application Executer</title>
    <HTA:APPLICATION ID="oMyApp"
       APPLICATIONNAME="Application Executer"
       BORDER="no"
       CAPTION="no"
       SHOWINTASKBAR="yes"
       SINGLEINSTANCE="yes"
       SYSMENU="yes"
       SCROLL="no"
       WINDOWSTATE="normal">
    <script type="text/javascript" language="javascript">
        function RunFile() {
      WshShell = new ActiveXObject("WScript.Shell");
      WshShell.Run("c:/MyProgram/NewTab.exe", 1, false);
        };
    </script>
</head>
<body>
<script type="text/javascript" language="javascript">
RunFile(); 
</script>
</body>
</html>


------------------------------------
So anyway, IT IS POSSIBLE to have tabbed browsing with Neobook, including a right-click menu action.

I am looking for ways to make it better, perhaps with fewer steps involved...

Instead of using a system tray app to open a new tab, I would rather have a command line switch directly to the parent Neobook publication. Is there any way of adding command line switches (myprogram.exe \s) to Neobook?

:idea:
.
User avatar
fkapnist
 
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece

Re: tabbed browsing

Postby Wrangler » Mon Dec 22, 2014 9:07 am

Look at the 'run' action. It has a place to enter switches.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1506
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA


Return to NeoBook and the Internet

Who is online

Users browsing this forum: No registered users and 0 guests

cron