Nov 8, 2009

Opening New Tabs With Javascript

free web hosting
Open Discussion > MODERATED AREA > Tutorials

Opening New Tabs With Javascript

clemen
I just spent a couple of hours trying to figure out how to open new tabs from a Firefox sidebar. I found lots of different suggestions but none worked. Well finally I found this and it works.

var browser = top.document.getElementById("content");
var tab = browser.addTab("http://www.google.com");

An even better way of doing it is through:

const kWindowMediatorContractID = "@mozilla.org/appshell/window-mediator;1";
const kWindowMediatorIID = Components.interfaces.nsIWindowMediator;
const kWindowMediator = Components.classes[kWindowMediatorContractID].getService(kWindowMediatorIID);
var browserWindow = kWindowMediator.getMostRecentWindow("navigator:browser");
var browser = browserWindow.getBrowser();
var tab = browser.addTab("http://www.google.com");

This will work from anywhere in Firefox. Sidebar, popup and ordinary pages.

got from Larry William's Weblog

XS: IE and Mozilla also provide the _search value to open links in the search sidebar.

 

 

 


Comment/Reply (w/o sign-up)

ill
you got to put quote tags around that, since you have got it from another site!

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : opening, tabs, javascript

  1. Surf Internet Without Opening It. Useful For School
    How-to! (21)
  2. Lesser Known Useful Javascript Features
    (2)
    Variables Javascript assigns every variable a type which changes as we assign different
    values to the variable. We can get the type of a variable using the ' typeof ' operator.
    For eg., CODE var hello = "Welcome to Trap17"; var year = 2008; alert(typeof hello );
    alert(typeof year ); The above lines will output the type of the first variable 'hello'
    as String and the second variable 'year' as Number . The types of Javascript variables
    are Boolean, Function, Number, Object and String . A variable with no explicitly assigned v....
  3. Make A Moderately-secure Password System Using Javascript
    using file redirection to hide the password. (11)
    JavaScript is very handy at making forms, allowing for much more customization and easier ways to
    send data. So making Login forms using JavaScript may seem to many to be a very feasable idea.
    However, JavaScript is very bad at protecting Passwords, as since the passwords are not encypted and
    the whole JavaScript code is in the page, a person could just view the Page Source and find out
    everything. Even if you use an external JavaScript, it would still be poor as the file name for the
    external JavaScript would still be revealed. But I have an answer! There is a relative....
  4. Simple Javascript And Password System
    How to protect your pages with password (10)
    The quickest way to get a password protection system up and running is to use a Prompt box in
    JavaScript that has a title like "Enter your Email Address". Only you and the relevant users know
    what the password should be, could even be one each, that can be sorted out at the next page then
    pass the "input" directly through the url by changing the .href, like
    http://www.iSource.net.nz/users/?leTmeIn= The page that then processes this should also check for
    the referring page, and three fails from an IP if you like the php (the next page): CODE //
    processdownloads.p....
  5. Opening Nat On Your Xbox - Upnp With Netgear
    for NETGEAR users with UPnP enabled (1)
    I think all of the NETGEAR Routers now come with UPnP Follow this tutorial and i will show you how
    to open your NAT. 1. Go to 192.168.1.1 (or 192.168.0.1 - or whatever they supplied you with) 2. Go
    down to maintenance and 'Attached Devices'. 3. My xbox is named '---' - most xboxes
    have that default name. 4. Make sure your xbox is located there and is in the IP you selected in
    your xbox wifi setup. 5. Now go down to 'Advanced' then 'UPnP' 6. If the
    'Turn UPnP On' is toggled - then uncheck it and apply. Then when it update....
  6. Create A Simple Html Editor With Php And Javascript
    (3)
    Ok, I will teach you how to create a simple HTML editor that runs online with buttons that add HTML
    tags. Before we start: You should have basic knowledge of these languages. HTML/XHTML
    Javascript PHP You will need Ability to use filesystem functions. Chmodding abilities
    Features of Editor Online PHP safe Full HTML support A Few Bad Features Can only create new
    documents or overwrite Fairly unsafe Now we are ready to begin. The PHP Script This will be
    our PHP script that we will use to make the file. Make a file called save.php Here is the....
  7. Mootools - My Favourite Javascript Library
    (3)
    It kind of amazes me that there's not even a mention of the Mootools javascript library
    throughout this whole forum. So here I'll do a brief introduction and a tutorial on how to
    produce the famous accordion effect. MooTools is a compact, modular, Object-Oriented javascript
    framework designed to make writing extensible and compatible code easier and faster. MooTools lets
    you get the job done efficiently and effectively. It is slightly based on the powerful Prototype
    javascript framework , of which Scriptaculous runs on. (But frankly, I dislike Scriptaculou....
  8. Javascript Scroll Bar
    A scroll bar for your webpage using javascript (13)
    In this tutorial I will show you how to create two buttons in the bottom left of the screen that,
    when hovered over, will scroll the page. Now to start with, we must create a our buttons, the first
    line will create a div element, or block. Using blocks you can position items anywhere on a page.
    We use the ID property just to let us know what the block is used for, as for the first block, its
    obvious that it contains the vertical buttons and the second two blocks contains the horizontal
    buttons. The style property of the div tag tells the browser how to draw it, in the....
  9. Simple Scripts In Html And Javascript
    Things like BackgroundColorChanger and so (7)
    like in the topic, here is a description how to change the Backgroundcolor "On The Fly", by klicking
    on a button or radio-box first, we ned the html-and body-tags, create a new html-file on your
    desktop and write the following: QUOTE browser interpretation: html - tag
    means "hey, browser, here comes HTML" in the body-tag you define the looking of your site. you can
    add things like "bgcolor" for the background, "text" for the textcolor and link / alink / hlink /
    vlink to define the linkcolor ( ) the scripttag is the tag, we'll need now (sorr....
  10. Javascript Framework - A Shortcut Javascript
    a shortcut javascript (3)
    hi, today im going to give you small tutorial how to use `Prototype JavaScript Framework` 1st you
    have to download `Prototype JavaScript Framework`library from http://prototype.conio.net/
    prototype makes easy to using Javascript, ex : when you want to point (get) the element from HTML
    usually we use : CODE document.getElementById('elementId') with prototype we use
    CODE $('elementId') , yeah...world getting small..with prototype. example we`re going
    to get value from an element of CODE with prototype we use CODE alert(....
  11. Tool Tips Using Only Css To Pop Up The Tool Tip
    No javascript involved! (8)
    Tool Tip Tutorial Example Found Here . Please review before continuing. Nice. And no
    javascript at all to be found. The colours I have used are for demonstration purposes only to show
    you that they are adjustable to suit the background or to contrast against them. Your choice. That
    is a styling issue. It is your site, you decide. The original author's idea was to add
    position:relative to the link, in order to allow the span element inside to position absolutely
    in respect to the parent link. This code has been tested in Ie5.5, IE6, Opera7.11 and M....
  12. Handy Javascript Code Snips
    Ready to Apply in your webpage (5)
    /tongue.gif' border='0' style='vertical-align:middle' alt='tongue.gif' /> Some common things to
    implement in our webpage very frequently are as follows. How to implement all these I am going to
    tell you in this tutorial. Add To Favorite Set As Homepage Go To Top Of Page No Right Click
    Print Page Adding Current Date Adding Current Time Pop-Up Page Creation Closing Window
    Copyright Notice Updation 01. Add To Favorite Someone may be interested in the content of your
    page. Offer him/her to add the page in his/her favorite menu. To do this you have ....
  13. Image Rollovers In Javascript
    A Write-Once, Use-Anywhere Approach (11)
    Tutorial: Image Rollovers w/ Javascript, by Rob J. Secord, B.Sc. (SystemWisdom) See a
    working Sample of this Script! Download a ZIP containing all working files in this tutorial!
    Note: If you are not interested in reading this entire tutorial and/or have a basic understanding of
    the underlying concepts, you may safely skip to the Implementation section to get the code!
    Description : A Dynamic Image Rollover Script tested to work in 4 major internet browsers: MSIE,
    FireFox, Netscape and Opera. Using only Javascript combined with regular HTML Images ( ....
  14. Css And Javascript Combined For Dynamic Layout
    use of different CSS files at same site (9)
    This tutorial is meant for people that are dealing with problems while coding their site at 100% of
    width. Important notice: Some people has JavaScript disabled, so they will not be able to load CSS
    file (take this in account when creating your website). How this script works. In the HEAD of your
    HTML document will apply this command, so variable.js file will be load at start: CODE
    In browser JavaScript file variable.js is loaded. This Javascript file consist of this parameters,
    copy this code and name it variable.js CODE // JavaScript Document if (sc....
  15. How To: Change An Image When A User Clicks On It
    using both php and javascript (12)
    How To: Change An Image When A User Clicks On It using both php and javascript - a powerful
    combination I have seen quite a few how tos offering a method of doing this but none of which
    resembled my method of making use of both php and javascript. This code is fairly repetitive and
    most of the functions are easy to pick-up if you haven't heard of them before. Here it is...
    Create your two images. Call them anything you like, you'd just need to change their filenames
    in $imgano $imgayes. In fact with this script you can easily create more than one pair....
  16. Creating Rollovers With Buttons
    Short & simple javascript tutorial that shows you how. (2)
    Javascript in action can render some very neat visual effects, which can make your website more
    appealing, and sometimes even easier to navigate. Among the most common effects are the
    'button' effect, and the mouseover effect. The buttons are very common, of course; if
    nowhere else, most of us have seen them at the end of forms (Click the 'submit' button to
    proceed...). The basic idea is to have a 'depressible' object, which can give you the
    illusion that you're 'pressing' it when you click it. The rollover effect causes
    something to h....
  17. Image Preloader With Progress Bar Status
    Pure Client-Side JavaScript tested in 4 Browsers! (28)
    Tutorial: Image Preloader with Progress Bar, by Rob J. Secord, B.Sc. (SystemWisdom)
    Description : A Tutorial for a Client-Side Image Preloader with Dynamic Real-Time Progress Bar
    Indicator written in JavaScript! Tested to work with 4 Major Internet Browsers: Firefox, MSIE,
    Netscape, Opera (Complete sample solution provided at end of tutorial, just put it on your
    web-server, add your images and go!) Intended Audience : Beginner to Intermediate Web
    Developers. Although this tutorial will cover some advanced aspects of JavaScript, I will try to
    explain it all ....

    1. Looking for opening, tabs, javascript

Searching Video's for opening, tabs, javascript
See Also,
advertisement


Opening New Tabs With Javascript

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com