Sign in to follow this  
7twenty

Some help with some basic code please

Recommended Posts

So i've been looking at some extensions and trying to figure out some things, but javascript is for the most part a little over my head. Reading some books to see if it makes any more sense.

Can anyone give me a quick rundown on how to do something as simple as close the current tab?

I get that this first two lines need to be in the script to create a runtime for the rest to work in, but then it gets hazy?

var rt = window.external.mxGetRuntime();
var browser = rt.create("mx.browser.tabs");

mx.browser.tabs.getCurrentTab()
Tab.close()

Line 3 should be "browser.getCurrentTab()" to get the current tab as it uses the browser variable? what next?

Where does Tab.close() fit in? Do i need to create a function for this to work?

Share this post


Link to post
Share on other sites

2 days, and no response.... well I think that shows just how many more technically inclined users there are here.

Share this post


Link to post
Share on other sites

i'll respond - only to say sorry i have no idea - javascript is a mystery to me - i think any that had knowledge have long since left - who in truth can blame them - it would be nice if one of the devs commented but thats asking far to much - its back to the one way street :wacko:

Share this post


Link to post
Share on other sites

Try this:

var myRuntime = window.external.mxGetRuntime();
var mxTabs = myRuntime.create('mx.browser.tabs');
var currentTab = mxTabs.getCurrentTab();
currentTab.close();

 

  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, 大笨狗 said:

Try this:


var myRuntime = window.external.mxGetRuntime();
var mxTabs = myRuntime.create('mx.browser.tabs');
var currentTab = mxTabs.getCurrentTab();
currentTab.close();

 

Hmmm, recognize the flower, thanx dev!

Edited by PHYR

Share this post


Link to post
Share on other sites
3 hours ago, PHYR said:

Hmmm, recognize the flower, thanx dev!

Likewise, I recognize the flower and the Chinese name, but didn't realize he's a dev (meaning Maxthon dev).  I do know his skin work,  very good and I'm still using one (Bing_Light) with some tweaks.

                            <<SL>>

Edited by SnowLeopard

Share this post


Link to post
Share on other sites
On Tue Dec 15 2015 00:03:21 GMT+1100 (AUS Eastern Summer, 大笨狗 said:

Try this:

Thanks for that :)

Amazingly the rest just seemed to fall into place once that was explained to me.

Learnt a few things which is nice!

Share this post


Link to post
Share on other sites
Sign in to follow this