Improvement requests :  K-Meleon Web Browser Forum
Use this forum to talk about a feature you're missing. 
Open in This Tab...
Posted by: mhf
Date: August 23, 2010 10:35AM

Could someone help me code this - in the page context menu we have :

Open in New Tab
Open in Background Tab
Open in New Window
Open in Background Window

how can I add Open in This Tab...? Which would of course open a link in the same tab. grinning smiley
I know that some links on some sites are hard-coded to do this but many are not.

Thanks.

Options: ReplyQuote
Re: Open in This Tab...
Posted by: JamesD
Date: August 23, 2010 11:35AM

Add an item to the context menu which uses the following command ID.

ID_OPEN_LINK
Opens the active link in the current browser window. 


Options: ReplyQuote
Re: Open in This Tab...
Posted by: e.g.
Date: August 23, 2010 11:57AM

LinkOpen{
%ifplugin tabs
Open In Ne&w Tab=ID_OPEN_LINK_IN_NEW_TAB
Open In Bac&kground Tab=ID_OPEN_LINK_IN_BACKGROUNDTAB

Open In This Tab=ID_OPEN_LINK
-
%endif
Open In &New Window=ID_OPEN_LINK_IN_NEW_WINDOW
Open In Backgro&und Window=ID_OPEN_LINK_IN_BACKGROUND
}


Options: ReplyQuote
Re: Open in This Tab...
Posted by: mhf
Date: August 23, 2010 11:58AM

Thanks James but I'll need a little bit more detail on how to do that...!

Options: ReplyQuote
Re: Open in This Tab...
Posted by: mhf
Date: August 23, 2010 12:01PM

Thanks e.g. - I replied to James before I saw your post. That's perfect.

Options: ReplyQuote
Re: Open in This Tab...
Posted by: Doon
Date: August 24, 2010 02:04AM

Hey there mhf, I was in the neighborhood so I provided that 'for example' to supplement James' advice. ;-)

I can understand why you'd want this functionality for particular sites, especially if you're already jUGGgling multiple open tabs. FYI, the core issue is that links in web pages use the html tag "href=" (with a page name/address following the equals sign) which by default opens in the current window/tab, but an additional html tag "target=" can be used to direct the link to open in a new or other open named window/tab -- these targeted links are the ones you're targeting, and your solution is a great way to manually override them.


Update: Don't do exactly what the next paragraph says! Follow Siria's posting below instead. ;-)

Furthermore (I'm such a bore), if one clicked Edit --> Configuration --> Menus to open the current user's "menus.cfg" and pasted in the entire code example provided above to a blank spot in the "menus.cfg", it would be enough to update the link context menu as requested. I mention this for the sake of anyone who might be reading this and didn't already know that menus can be changed and updated so easily in this manner.



Further still, I'll shamelessly link yet again to my own early compilation of customization advice written by a newbie for newbies, which covers some basics of menu editing and other useful things: http://kmeleonbrowser.org/forum/read.php?1,96463

And always worth mentioning is desga2's massively useful K-Meleon Quick Guide (for usable commands): http://two.xthost.info/kmeleon/lizard/commands.html



Edited 1 time(s). Last edit at 08/25/2010 01:05AM by Doon.

Options: ReplyQuote
Re: Open in This Tab...
Posted by: mhf
Date: August 24, 2010 03:13PM

Thanks doon for all the information ( though I did know some of it ...smiling smiley ) but the link to desga2's K-Meleon Quick Guide seems to be dead ???

Options: ReplyQuote
Re: Open in This Tab...
Posted by: JamesD
Date: August 24, 2010 03:30PM

I got desga2's page to display just minutes ago. http://two.xthost.info/kmeleon/lizard/commands.html

Options: ReplyQuote
Re: Open in This Tab...
Posted by: mhf
Date: August 24, 2010 05:17PM

Yes it displays now but it was down !

Options: ReplyQuote
Re: Open in This Tab...
Posted by: Doon
Date: August 24, 2010 09:15PM

Regarding sites known to have targeted links, I didn't think to mention this earlier but when I don't want such links to create new windows I drag the link and drop it on the current tab in order to force it to open in the current window. Your handy new context menu option is surely quicker but they both accomplish the same goal. -more tips-



Edited 1 time(s). Last edit at 09/25/2010 06:06AM by Doon.

Options: ReplyQuote
Re: Open in This Tab...
Posted by: siria
Date: August 24, 2010 10:18PM

To be honest I've kept wondering first, why don't you simply left-click a link?? :cool:

But okay, that target thing makes sense ;-)

Not sure if it was mentioned already, there exists a pref setting to ignore "new targets":
Edit > Preferences (F2) > Browsing, the famous "Window Diversion".
"Links meant to open a new window" -> open in the current tab.


I wasn't really aware about pulling links into the current tab, good idea! grinning smiley

Quote
Doon
Edit --> Configuration --> Menus to open the current user's "menus.cfg" and pasted in the entire code example provided above to a blank spot in the "menus.cfg", it would be enough to update the link context menu as requested.

My first thought: Clever! :-) My tenth thought: Hmm... lets see how that works with macro-created menu entries... Oops! Not good, it deletes them all sad smiley Because it not just "changes" the menu, but creates it whole new, "overwrites" it completely.

Changing the default menus.cfg probably gives no problem to macros, but on the other hand, changing default stuff changes that in all new profiles too. Can get confusing if debugging, no "original" profiles anymore :-/

But there is a way to really just "add" (or remove) single lines to existing menus, without touching the others. Instead of pasting the "entire code" just paste the modifications:

!LinkOpen{
Open Here=ID_OPEN_LINK|ID_OPEN_LINK_IN_NEW_TAB
}


The "!" means "modify this menu", the second line means:
Insert "Open Here" right above "Open in New Tab"

Uhm, has anyone tried if that command really ignores the targets...?

PS: The evil "ugg" works again, since a few days grinning smiley



Edited 2 time(s). Last edit at 08/24/2010 10:24PM by siria.

Options: ReplyQuote
Re: Open in This Tab...
Posted by: Doon
Date: August 25, 2010 01:08AM

Excellent information and corrections, Siria.

Learning new stuff every day: very good point about the menu modifying exclamation point (!). Your simplified code is definitely the best choice by far (I'll edit my posting to reflect this). The trick of adding an ID after a "|" to determine menu order is new to me, but it still leaves a bit to be desired, such as when dealing with a menu divider ( - ). But while experimenting just now I realized that using a number after the "|" can determine the menu position also, based on index numbers starting with zero (0,1,2,3,etc.).

Which means that this code:

!LinkOpen{
Open In This Tab=ID_OPEN_LINK|2
}


...would replicate exactly what the original whole-menu code accomplished (including menu order), but without the harmful side effects. Thank you! This has taught me a lot.

And yes siria, "that command really ignores the targets". smiling smiley


Good call on the window diversion preference, and yep, using a menu's internal name (LinkOpen) and contents in the basic menus.cfg does in fact (by design) replace that menu's contents entirely (which was foolish in this instance), but I didn't realize (or remember) that it would affect other macro based menu changes.

I've already half forgotten the details but I seem to remember now that macro based menu changes can be better and offer more flexibility than .cfg based changes (not that I know much about making them, and my menu CFGs are a total mess). The problem is that macro based changes can be far more complicated for a new user.

Just for kicks, this is the same thing as above in standalone macro form:
OpenInThisTab{
setmenu(LinkOpen,command,"Open In This Tab",ID_OPEN_LINK,2);
}

$OnInit=$OnInit."OpenInThisTab;";
$macroModules=$macroModules."ThisTab;";



evil ugg -- I hoped some would smile at that, hehe.

Options: ReplyQuote
Re: Open in This Tab...
Posted by: mhf
Date: August 25, 2010 10:40AM

Learning something every day makes KM happy - and me.

Thanks for the updates about different ways of doing this and especially the exclamation mark... siria, sometimes I want links (targets) to open in a new tab but not all the time...!

I started this thread as I'm a mouse-and-context-menu freak and was particularly annoyed when, an example among many others, wanting to look at some screen shots and each one opens in a new tab - which you then have to close...



Edited 1 time(s). Last edit at 08/25/2010 10:41AM by mhf.

Options: ReplyQuote
Re: Open in This Tab...
Posted by: anni
Date: September 17, 2010 06:09PM

Quote
JamesD
Add an item to the context menu which uses the following command ID.

ID_OPEN_LINK
Opens the active link in the current browser window. 

yeah ok. thanks for this one.



Edited 1 time(s). Last edit at 09/17/2010 07:36PM by guenter.

Options: ReplyQuote
Re: Open in This Tab...
Posted by: siria
Date: September 17, 2010 06:45PM

SPAM-Link.

Options: ReplyQuote
Re: Open in This Tab...
Posted by: guenter
Date: September 17, 2010 07:38PM

brav :cool:smiling smiley

brauchte nicht denken & nur noch editieren oder löschen smiling smiley

Options: ReplyQuote


K-Meleon forum is powered by Phorum.