Posts tagged ‘Opera’

Easy PHP Search with Opera

If you use Opera you’re probably aware that it supports shortcuts in the address bar that allow you to run a search on various search engines and websites. For example, if I type g tinsology in the address bar, you’ll get the Google search results for the keyword tinsology. You can do similar things with yahoo, amazon, ask and other sites that come preconfigured in Opera.

Personally, I find myself frequently using this shortcut to Google PHP documentation. For example if I’m looking up documentation for the implode function, I’ll type g PHP implode. More often than not the first result is what I’m looking for and it is just a matter of waiting for the search results to load, clicking the first result, and waiting for the php.net page to load.

Ideally, however, I would want to be able to go directly from typing my search in the address bar to the php.net results page. It just so happens that Opera allows you to do this by adding a custom search engine. What we want to do is to be able to type p [my search] in the address bar. To begin we need to open the Search Preferences pane:

  • In Opera click Tools -> Preferences... or press Ctrl+F12
  • In the resulting window select the Search tab.
  • Click the Add... button.

In the add window there are three fields we are interested in: Name, Keyword, and Address (if you don’t see the address field click the details button). Name is just the name of this search shortcut; I named it PHP, but it doesn’t really matter what you name it. Keyword is the keyword you type in the address bar before your search query. For a Google search it is g. I chose p, but once again you can choose anything you’d like. Also, the keyword doesn’t have to be a single letter, for instance you could use php. The address field tells Opera what to do with your search query. Without explaining too much I’ll just say that the value we want to use is: http://us2.php.net/manual-lookup.php?pattern=%s. The %s token will be replaced by our search query. For instance typing p implode will cause Opera to open http://us2.php.net/manual-lookup.php?pattern=implode

That’s it; leave all of the remaining field blank. You can now use Opera’s address bar to instantly search the PHP documentation. You can use similar methods for running searches on other sites, the hardest part is finding the correct search URL (its even harder if the search query cannot be URL encoded, that’s when the Use Post option comes in handy).

Opera: A developer’s browser

My previous entry will suggest to the reader (and by suggest I mean scream aloud) that I am not fond of IE. In addition to this I mention that I use Opera as my primary browser. Typically for windows users, if you are not using IE you are using Firefox. Opera is a less popular browser, but I think much more useful for developers.

Out of the box Opera has several features that have made my life easier many times. One of them is fairly simple: if you want to validate a page, all you have to do is right click and click validate.

Another feature allows you to dynamically update the source code of a site. All of the popular browser allow you to view a page’s source, but Opera allows you to view that source, edit it, and have the changes applied to the currently open page. This if very useful for making adjustments to a layout, or on occasion, making a broke page work. For example, I was trying to register on a site using a captcha. Normally this isn’t a problem, but in this case the text field only allowed 4 characters, while the image contained 5. All I had to do to work around this was view the source, and change the size attribute to 5. This is the only case I can think of off the top of my head, but there are others.

This is just the tip of the iceberg. Opera’s developer console lets you view the DOM structure of a site and view cookies. If a site is hard coded to only work in IE or firefox, Opera can identify itself as either of those. If you want to open a page in another browser all you need to do right click select open with and choose any installed browser. The list keeps going.

If you haven’t given Opera a try you should definetly do so.

Internet Explorer No Longer Essential

I haven’t used IE as my primary browser for a long time. I switched from IE to Opera several years ago. Until recently, however, I’ve always had Internet Explorer installed. This is because there always seemed to be some website that either insisted on users using IE, or was coded in such a way that it only worked in IE. It seems counter-intuitive to me that the browser that is the least standards complient should be the one that everyone codes there website to work with, even at the expense of all of the other browsers, but that was the reality of the industry for a long time. Only now do I believe that that era is almost over; it is now possible to uninstall IE permanently.

The actually came to this conclusion by accident. A few months ago, my cable provider forced me to reactivate my Internet connection. This was altogether a very clumsy and inconvenient process. It consisted of me entering some personal information along with an account number and then waiting for their system to recognize my modem. Not only did this take an incredibly large amount of time, but I also had to complete the entire process in IE6. When I say IE6 I really mean IE6… their software downgraded IE7 without asking. Around an hour an a half later when the process was complete I found that this extremely (really I can’t stress this enough… Cox Communications I hope you read this) poorly written software had crippled IE. It crashed the moment I opened it.

Not wanting to deal with the additional stress of fixing this problem, having just spent a considerable amount of time dealing with my cable company, I happily went about my business, using Opera as my primary browser as always. A few days ago I clicked the IE icon by mistake and was reminded that it was still crippled. After a few months I had not yet needed to open IE even once. This came as a surprise to me as in the past I had occasionally needed to use IE to do things like accessing my bank account and watching certain videos.

So what is the blame for this development. Part of it, I think, is that developers have been (finally) focusing more on cross-browser support. Another part is the browsers themselves; Opera has a feature to identify itself as other browsers, which i nice for circumventing sites that are hardcoded to only allow FireFox or IE. Regardless of what is responsible, I think this is a step in the right direction.

Opera Tab Override User JS

A few days ago I released a WordPress plugin that overrides the default tab keypress action. This means when you press tab it inserts a tab character rather than moving focus from one field to another. I made a few modificaitons to this script in order to turn it into an Opera UserJS application. To use Tab Override for Opera, copy the following code and place it in a file called taboverride.js in your UserJS file:

function operaTab(e)
{
	if (e.keyCode == 9)
	{
		var obj = e.target;

		obj.selection = document.selection.createRange();
		obj.selection.text = String.fromCharCode(9);

		e.stopPropagation();
		e.preventDefault();
	}
	return false;
}

function tablistener(){
	var textareaArr = document.getElementsByTagName('textarea');
	for( var i in textareaArr )
	{
		textareaArr[i].addEventListener('keypress', operaTab, true);
	}
}
window.onload=tablistener;

Using UserJS
If you don’t have UserJS enabled or are unsure if it is enabled, here’s how you do it:

  • In Opera, on the toolbar click Tools -> Preferences...
  • Click the Advanced tab and select the Content submenu.
  • Make sure Javascript is enabled and click the JavaScript Options... button.
  • Under User JavaScript Files should be the path to your userjs file. The default is C:\Program Files\Opera\userjs.
  • If the path is not set, set it to the default. All you need to do to activate a User JS file is add it to the specified folder.

Some Issues with the script

The script will only work on textarea fields. This is intentional, as in other fields the default tab action is preferable. If you want to override all tabs, modify the line var textareaArr = document.getElementsByTagName('textarea'); to read var textareaArr = document.getElementsByTagName('form');

The script won’t work on some platforms due to interfering scripts. I’ve experienced this on some but not all vBulletin forums. I believe it is possible to override these scripts, but I have not yet figured out how.