• Using SSI For Auto Updates

    Date: 2011.02.24 | Category: WebDesign | Response: 0

    We all realize the benefits of being able to save time when building sites so, I got into thinking, how can I make my sites look as if they are continually updated without the need to go in and update them manually? Enter the world of SSI.

    SSI is actually a nifty little tool, not only can you include files from a central location but, you can include them at specific times of the day, days of the week or even months of the year, very handy indeed if you are building any type of site that needs updating periodically.

    Once the main burst of work has been completed you can pretty much use the same files over and over again to help you out.

    So onto the auto updating SSI, the following SSI coding will enable you to update a page or pages based on which day of the month it is. It will check the day the page has been accessed and display the relevant information again, this is a handy thing to have should your sponsor be running a promotion over several days, all you need to do is update a selection of SSI files and all of your sites are updated instantly.

    <!–#config timefmt=”%d”–>
    <!–#include virtual=”/yourdirectory/$DATE_LOCAL.txt”–>

    What you need to do is create 31 text files named 01.txt right the way through to 31.txt take the SSI call above and edit the location of the SSI files on your server, you may like to have a central folder named /SSI/ for this purpose so the location would be changed to /domain.com/SSI/$DATE_LOCAL.txt

    I the 31 files you created you could have a table ad with eight of your sponsors links, an article in each one or even just a simple text link, anything that you may want to update can be included in these files.

    As I mentioned above you can base the time, date and even month of rotation to whatever you like to alter how the files are rotated and ultimately viewed on the web you should change the %d in the timefmt field to one of the following:

    %d : Day of the month requires 31 files named 01.txt to 31.txt
    %w : Day of the week requires 7 files named 0.txt to 6.txt
    %j : Day of the year requires 365 files named 001.txt to 365.txt
    %u : The week of the year requires 52 files named 00.txt to 53.txt
    %m : The month of the year requires 12 files named 01.txt to 12.txt
    %H : Hour of the day requires 24 files named 00.txt to 23.txt
    %M : Minute of the hour requires 60 files named 00.txt to 59.txt

    As you can see from the above there really are no limitations to the uses of updating using SSI and, apart fro the relative ease of use and the time saved using them should one sponsor not be converting for you all you need to do to swap sponsors is alter your central set of SSI files and you have instantly changed sponsors over all of your sites.

    Article written by Lee

  • What’s In A Niche?

    Date: 2011.02.24 | Category: General | Response: 0

    Many webmasters realize what the different ‘fetishes’ the surfers have are but, how many of us realize these are actually niches and, how many of realize that these niches can be broken down into smaller sub niches of the particular fetish the surfer is looking for?

    Lets take an example of say, the ‘lesbian’ niche.

    Of course we all know what the lesbian niche entails, two women getting naked with each other right? Wrong.

    There is much more to it than that, for example, obviously lesbian sites appeal to, well, they appeal to guys who want to fantasize about getting it on with two women but, what about the female surfers? Sure, some women probably join lesbian paysites too.

    That’s one ‘sub-niche’ of lesbian right there, this can be broken down even further though for examples, Ebony Lesbians, Teenage Lesbians, Mature Lesbians, the list goes on and on and on.

    So how do we choose a niche to market in adult?

    The first and foremost thing you should try when choosing ‘your’ niche is to try something that either excites you or, appeals to you in a non sexual manner, if you are into Lesbian Midgets getting it on, then start off with that for your niche.

    Likewise, if guys getting down and dirty is the thing that floats your boat, choose that as your niche, you should already know enough about the niche you choose primarily to be able to sell something to the surfer. If it excites you, it will more than likely excite a surfer and result in a sale.

    Of course, the above statement isn’t always true, I know plenty of straight webmasters who market the gay niche VERY successfully, they have found a method that works for them and developed their business from there it probably wasn’t easy at the start but, nothing easy will make you the ‘real’ money that there is in adult.

    You need to experiment, constantly adapt and change the way you do business, if you try something and it doesn’t work, ask yourself why, what could you have changed that might have made a difference and, instead of changing it on the first site you built, change it on your next one, that way, even though it may not work at this moment in time, you will no doubt find it will work at a later date just as you will find that something that works well for you now may not work at all later on in your business career.

    Once you have mastered a general niche you should then think about trying some of the sub niches that are available to you, there is more to teen than than just cute teenage girls lying naked on a bed and getting screwed rotten by some guy. just as you saw there was more to the lesbian niche above.

    Take your sponsors tour for ideas, often you will notice things that spark some though and, once you have that spark, you should ensure it develops into a flame.

    Even something as simple as a tattoo on a model or a piercing can be the tart of a whole new niche, look at the things that other webmasters may not be, just because there isn’t a proliferation of teenage pierced lesbian sites, doesn’t mean that someone doesn’t want to join one and, who knows, that weird sexual fetish you build a site for now may become popular in 6 months time.

    Basically, what I am trying to say is that as adult webmasters we need to investigate all aspects of the niche we want to or, currently do market, just because a surfer comes to the front page of a lesbian site, doesn’t mean that they wont also be interested in an ebony site, its all down to how we market our sponsors paysites as webmasters.

    Article written by Lee

  • Promoting Safe Sex In The Adult Industry

    Date: 2011.02.24 | Category: General | Response: 0

    To most webmasters, the only thing that needs to be considered when building and marketing our websites is the layout of the site, the sponsors that they will be using and ultimately, the amount of money they will make from the site however, there is another side of the adult industry that we should also be considering, the moral side.

    Safe Sex – Morally Speaking.

    We all have our own morals and work ethics however, I think that sometimes most of us push these to the back lines a little when it comes to making a buck which is understandable however, we are in a position of power somewhat over a lot of things that many of us do not even think about, we know that for the vast amount of industry webmasters there are more than 90% of them will actively report child porn sites when they find them however, how much further does this reach and, how much harm could you potentially be doing long term?

    Promoting Safe Sex – The Issues At Hand.

    Step out of your webmaster persona for a short while now while you read this next paragraph and actually think about what is being said, all of us in our communities realize that sexually transmitted diseases and especially HIV/Aids is on the increase although maybe not reported as much the one thing that you can be certain about whether you go to a gym, a bar or a doctors is that we are constantly shown images promoting safe sex, ask yourself how you feel about that and, furthermore, ask yourself if you would have unprotected sex with someone if the answer to this question is yes then the rest of this article will be of no consequence to you however, if the answer is no, then you may like to read on.

    Safe Sex Online.

    Now we have ascertained how you feel about safe sex, why do you not promote this more often on your sites and galleries? We are giving surfers a product that will, in all likelihood fulfill their fantasy and, quite possibly, be mimicked by them at some point in the future. With this in mind I would suggest the following to you if I may. When purchasing content, try to purchase photosets where the models are practicing safe sex, if a surfer see’s a famous porn star using a condom then, ultimately, they themselves may use a condom when they next have sex. When building a site or gallery why not promote a condom affiliate program on the site, either through the use of a text link or a button or banner, not only are you being responsible but, you are also still going to make money should your surfer buy something from your condom sponsor. A good sponsor for Condoms is http://www.condomexpress.com.

    Promoting Safe Sex – The Bigger Picture.

    As mentioned in the opening paragraph of this article, more often than not, webmasters choose to go with bottom line profits over their morals however, thankfully this isn’t always the case. Whether you decide to start promoting safe sex as a method to promote condom sales or, whether you choose to promote safe sex as it is a moral that you believe in, one thing alone will stand true, by showing the surfer that sex can be safe and fun, we are definitely doing our part towards making sure that not every webmaster is seen as morel-less.

    Article written by Lee

  • Using .htaccess Effectively

    Date: 2011.02.24 | Category: WebDesign | Response: 0

    The .htaccess file is an ASCII text document that can be placed in any directory on your site. It can be used to control access to files and directories, and customize some server operation in your site. A .htaccess file can be created in any word processor but must be saved as text only. You must use FTP software in ASCII mode to upload or edit your .htaccess file. For the examples provided here, place the .htaccess file in your root directory.

    There are a variety of functions that you can control using .htaccess some of the more useful of these are explained below:

    Custom Error Messages.

    Add the following to the .htaccess file::

    ErrorDocument 404 /notfound.html

    After “ErrorDocument” specify the error code, followed by a space, and then the path and filename of the .html file you would like to be displayed when the specified error is generated, each specific error code is detailed below with the recommended codes to be used in the .htaccess file in bold :

    200 OK
    206 Partial content
    301 Document moved permanently
    302 Document found elsewhere
    304 Not modified since last retrieval
    400 Bad request
    403 Access forbidden
    404 Document not found
    408 Request timeout
    500 Internal server error
    501 Request type not supported

    Using the codes above your error section of the .htaccess file should look like this:

    ErrorDocument 301 /notfound.html
    ErrorDocument 400 /notfound.html
    ErrorDocument 403 /notfound.html
    ErrorDocument 404 /notfound.html
    ErrorDocument 500 /notfound.html
    ErrorDocument 501 /notfound.html

    Redirect to a Different Folder.

    Add the following to the .htaccess file:

    RewriteEngine on
    RewriteRule ^/oldfolder(.*)$ /newfolder/$1 [R]

    This redirects the user from /oldfolder/anyfile.html to /newfolder/anyfile.html, when the .htaccess file is uploaded to the otherwise empty “/oldfolder” directory.

    Denying User Access.

    Add the following to the .htaccess file:

    <Limit GET>
    order allow,deny
    deny from 000.00.00.
    deny from 000.000.000.000
    allow from all
    </Limit>

    This is an example of a .htaccess file that will block access to your site to anyone who is coming from any IP address beginning with 000.00.00 and from the specific IP address 000.000.000.000 . By specifying only part of an IP address, and ending the partial IP address with a period, all sub-addresses coming from the specified IP address block will be blocked. You must use the IP addresses to block access, use of domain names is not supported

    Redirect a Machine Name.

    Add the following to the .htaccess file:

    RewriteEngine On
    Options +FollowSymlinks
    RewriteBase /
    # Rewrite Rule for machine.domain-name.net
    RewriteCond %{HTTP_HOST} machine.domain-name.net $
    RewriteCond %{REQUEST_URI} !machine/
    RewriteRule ^(.*)$ machine/$1

    This will redirect requests for the machine name machine.domain-name.net to the directory machine on the site domain-name.net.

    Different Default Home Page.

    Add the following to the .htaccess file:

    DirectoryIndex filename.html

    Then a request for http://domain-name.net/ would return http://domain-name.net/filename.html if it exists, or would list the directory if it did not exist.

    To automatically run a cgi script, add the following to the .htaccess file:

    DirectoryIndex /cgi-local/index.pl

    This would cause the CGI script /cgi-bin/index.pl to be executed.

    If you place your .htaccess file containing the DirectoryIndex specification in the root directory of your site, it will apply for all sub-directories at your site.

    Preventing Hot Linking.

    Add the following to the .htaccess file:

    # Rewrite Rule for images
    RewriteCond %{HTTP_REFERER} <URL of page accessing your domain>
    RewriteRule ^(.*)$ http://<same as above URL>

    You would replace the <URL of page accessing your domain> above with the domain name and path of the page that is referring to your domain. For example: www.theirdomain.com/users/mypage/

    The RewriteCond directive states that if the {HTTP_REFERER} matches the URL that follows, then use the RewriteRule directive. The RewriteRule directive will redirect any reference back to the referring web page.

    Using the above you should, safely be able to publish your sites on the internet knowing that you will not be privy to bandwidth thieves via hotlinking and also, that you will not lose any traffic through pages that are ‘not found’.

    Article Written By Lee

  • Traffic Filtering – Country Specific Redirects

    Date: 2011.02.21 | Category: Traffic | Response: 0

    To some, actually marketing to foreign surfers is a waste of time rather than a business practice. Unfortunately, they are missing out on additional revenue. We are already beginning to see some of the major sponsors in the adult industry embracing these foreign markets and, not just by utilizing dialers.

    However, filtering your traffic base is often the hardest part of this money making equation. That is where the following piece of PHP coding can come in handy.

    PHP FILTERING CODE

    <?
    $user_lan = $HTTP_ACCEPT_LANGUAGE;

    if($user_lan==’de’) {
    ## German
    $redir_url = “http://www.germanlanguagepageurl.com”;

    } elseif($user_lan==’fr’) {
    ## French
    $redir_url = “http://www.frenchlanguagepageurl.com”;

    } elseif($user_lan==’it’) {
    ## Italian
    $redir_url = “http://www.italianlanguagepageurl.com”;

    } elseif($user_lan==’es’) {
    ## Spain
    $redir_url = “http://www.spanishlanguagepageurl.com”;

    ## US traffic or Rest of world not defined above
    } else {
    $redir_url = “http://www.yourmainpageurl.com”;

    }

    header(“Location: $redir_url”);
    exit;

    ?>

    So, we know that the above piece of coding can redirect surfers based on their country of origin however, in order for you to maximize this to its full potential you will need to know the country specific codes (Also called ISO 639 codes) for each of the main browser languages. Some of these are as follows.

    da | Danish
    de | German
    en | English
    es | Spanish
    fi | Finnish
    fr | French
    it | Italian
    jp | Japanese

    The problem you now have is finding where to send your filtered country specific surfers to. Of course, there is always the dialer option however, this is not going to be as lucrative to your wallet as what most people will have you believe.

    In fact, I very rarely use a dialer on my foreign traffic instead, I tend to send them to a language specific tour page from one of the big sponsors and, if they do not sign up to that sponsors site, this is the point where I throw a dialer at them and, if the dialer still doesn’t make any money off the surfer I then recycle the surfer for a fresh one through a toplist or banner exchange heavy page.

    In doing this I find it is often more productive than ‘regular’ English speaking traffic as, if you give the surfer something they are looking for, they will be more inclined to buy.

    Hopefully this article has given you some insight into filtering and using your foreign traffic as oppose to just sending them off to a dialer program.

    Article written by Lee

  • Converting French Traffic – The Niche Paysites That Work

    Date: 2011.02.21 | Category: Traffic | Response: 0

    In our last article we took a look at a three (3) month period of international traffic stats and, what niches worked on German adult traffic. In this article we will do the same again except we will be analyzing what niche paysites worked best on French porn surfers.

    French Traffic – Quick Analysis.

    It would seem that for many of the surfers we managed to grab and filter from France that their primary interest was in Teen and the Amateur niches although, that said, we did get a few conversion on some fetish paysites, specifically fetish sites that had ‘watersports’ and ‘BDSM’ featured on the paysites tour pages.

    French Adult Traffic – The Niches.

    As with the German traffic we targeted in the previous article we also filtered our French adult traffic to some niche specific hub sites as well as some general hub sites to better judge which niches converted the best on French surfers the results we experienced are as follows.

    Teen.

    Our conversions on French teen sites were not as good as what they were for German surfers however, that said, they were good non the less. With a ratio of around 1:192 over the three month period we analyzed the French adult surfers we managed to get to our sponsors sites worked well for us.

    Amateur.

    With our amateur conversions the one thing we noticed was that tours that featured teens as the main focus were the ones which converted consistently, with this in mind, we did change a couple of the Amateur tours we used to see how that would affect sales towards the end of the 3 month period and, sales did drop slightly, this would backup the statements in the Teen niche made above in that, French surfers are looking primarily for Teen orientated paysites.

    Asian.

    The two Asian niche paysites we used didn’t have many sales overall however, we did notice that the little traffic that we sent to them converted well, as above, Asian niche sites that featured teens were again the better converters on the French traffic we received.

    Ebony.

    I think it is worth mentioning the ebony niche, especially when you take into account we sent less than 100 hits to French ebony paysites and, managed to get 2 sales from those hits. Unfortunately, we did not anticipate the amount of traffic that wouldn’t choose the ebony niche so we have no solid figures that are worth mentioning here or, any explanation behind how we made the sales.

    Fetish.

    Our French fetish traffic seemed to like the more niche specific type of tours, making us sales on Watersports, BDSM and even general fetish paysites that said, the figures we achieved with the fetish pay sites we used were disappointing as we had thought this would be the ideal niche for the French markets.

    Gay.

    The sales we achieved with our gay French traffic were reasonable overall, the surfers chose to signup to gay sites that featured ‘twink’ like models on the tours again, this would lend favor to the fact that overall French surfers seem to be interested in the younger generation to get their kicks.

    French Traffic – The Results.

    Overall we were happy with the majority of the results we received on our French adult traffic with the exception of a few bad choices on our part trying to concentrate on the Fetish side of the industry. We certainly learnt that it would appear French adult surfers are looking for Teen orientated sites over the other niches.

    Article written by Lee

  • Saving Time Online – Shortcut Keys

    Date: 2011.02.24 | Category: General | Response: 0

    The one thing that i have started to do just lately is use shortcut keys. These are actually very easy to get used to and, will save you a lot of effort over a period of time.

    Below you will find a list of the more common shortcut keys in both Windows and Internet Explorer.

    Even if you get used to using one or two of these shortcut keys you will notice the time you start save over a week, hell, i don’t even type the whole domain into my IE address bar anymore!

    Here are the shortcuts for Windows along with the description of what they do:

    Alt + F – File menu options in current program.
    Alt + E – Edit options in current program
    F1 – Universal Help.
    Ctrl + A – Select all text.
    Ctrl + X – Cut selected item.
    Shift + Del – Cut selected item.
    Ctrl + C – Copy selected item.
    Ctrl + Ins – Copy selected item
    Ctrl + V – Paste
    Shift + Ins – Paste
    Home – Goes to beginning of current line.
    Ctrl + Home – Goes to beginning of document.
    End – Goes to end of current line.
    Ctrl + End – Goes to end of document.
    Shift + Home – Highlights from current position to beginning of line.
    Shift + End – Highlights from current position to end of line.
    Ctrl + Left – Moves one word to the left at a time.
    Ctrl + Right – Moves one word to the right at a time.
    Ctrl + Backspace – Delete word to the left of cursor.
    Ctrl + Del – Delete word to the right of cursor.
    Alt + Tab – Switch between open applications.
    Alt + Shift + Tab – Switch backwards between open applications.
    Ctrl + Esc – Bring Up start button.
    Alt + Esc – Switch Between open applications on taskbar.
    F2 – Renames selected Icon
    F3 – Starts find from desktop
    F4 – Opens the drive selection when browsing.
    F5 – Refresh Contents
    Alt + F4 – Closes Current open program.
    Ctrl + F4 – Closes Window in Program
    Alt + Enter – Opens properties window of Selected icon or program.
    Shift + F10 – Simulates right click on selected item.
    Shift + Del – Delete programs/files without throwing into the recycle bin.
    Holding Shift – Boot safe mode or by pass system files.
    Holding Shift – When putting in an audio cd will prevent CD Player from playing.

    The following list are shortcut keys when using Internet Explorer:

    Alt + Left – Back a page.
    Alt + Right – Forward a page.
    F5 – Refresh current page / frame.
    Esc – Stop page or download from loading.
    Ctrl + Enter – Quickly complete an address.
    Ctrl + N – Open New browser window.
    Ctrl + P – Print current page / frame.

    Hopefully this list of shortcut keys will get you saving some time even if its just a few minutes a day. After all, we all know the one thing webmasters need more of is time.

    Article written by Lee

  • The Adult Internet – More Than Just Porn

    Date: 2011.02.24 | Category: General | Response: 0

    So you have several adult websites up and running and, if you are one of the lucky few in this day and age you have already started to make money from your adult sponsor programs however, there are so many other ways that webmasters can make money in the adult industry in addition to their regular ‘porn site’ sponsors yet, many webmasters do not realize there are vast opportunities awaiting them.

    Lets spend a few moments to look at the alternative sources of income that we can use in the adult industry and also take a look at the basics of each type of affiliate system.

    Email Collection.

    Opt in email is big business, there is no denying this fact so why not jump on the opt in email collecting bandwagon? Most email collection sponsors will offer you anywhere from $0.50 per email collected to $2.00 per email collected and, better still, to start making money from your existing traffic base all you need to do is include a small email collection box.

    Software Programs.

    Many of the larger adult affiliate programs now offer their webmasters a range of software products to generate additional income, many of these products are good for use not only in adult but, also in mainstream. For instance, Anonymous browsing software, history deletion software, IE Toolbars and even submission programs are all good ways to generate additional income either on a per download or, per sale basis. Best of all, you only need to add a new banner to the sites you currently have in order to get a share of this lucrative market.

    Herbal Products.

    Penis Pills, Breast Enlargement, Vitamin Supplements, you name it you can sell it on adult traffic. Whether you run a TGP, Link List or your own collection of free sites, these herbal products can often sell much better than ‘porn sites’ and, for the most part, the payout levels are the same, if not higher than what your regular ‘porn site’ trial will make you. Again to get started with this type of sales all you need to do is add a text link or banner to your existing sites.

    Casino Sites.

    Gambling makes BIG money, just look at Vegas for the example, millions of people a year visit Nevada to gamble and millions more simply can’t get there for a range of reasons however, almost every home in the United States has a computer and internet connection so why not start using this to your advantage? Many of the larger casino affiliate programs will pay based on the amount of funds credited to a new users account and, to get started making money from casino sites it is quite literally as easy as adding a banner or text link to your existing sites again.

    Pre Paid Services.

    Such as Credit Cards and the likes, selling these types of products to your adult surfers not only offers then ‘anonymity’ on the web when they do make online purchases but at the same time when your surfers sign up or one of these pre-paid credit cards you will be making some money in the process. Often however you will find that these types of affiliate program do not payout as much ‘long term’ as they are pretty much a first time deal as far as, once the surfer spends money to initially ‘charge’ their pre paid card with funds, that is when you will make money and not again. Still, even if you can make $50 by selling one of these cards, its still an additional $50 you wouldn’t have made otherwise.

    Adding To Your Profits.

    As you can see from the above, there are a wide range of products and services you can offer your surfers and, as we all know, the more things we can offer our ‘customers’ the more chance we have at one of them buying something. Of course, as with anything, the more effort we put into marketing these products and services the more chance e have at making a sale however, unless we try to sell the surfer something other than porn, how will we know whether they will buy or not?

    Article written by Lee

  • Marketing to Foreign Surfers

    Date: 2011.02.22 | Category: Promotion | Response: 0

    Marketing to Foreign Surfers.

    What would you do if I told you that there are 3 million plus new surfers last year that you did not market too? You probably marketed your product or adult site to those that could read English well enough to be searching with English terms. How about the growing numbers of surfers with English as their second language?

    According to Nielsen/Net Ratings, from September 2000 to 2001, Italy’s online population grew by 3,540,970 users: about one new user every ten seconds. Italy is just one of the non-English speaking countries that is coming online at lightening fast speed.

    Are you relying on these surfers searching for your English keywords? Are you thinking that every language uses the words “porn and hardcore” and what about the finer niches like “bisexual and titties”? The best conversion is with newbie surfers just online for the first time and wanting to see adult sites and products. Those that have been around a while find out about the plethora of free porn. This means that websites do their best marketing with search engine placements of their main sites or feeder sites. If you are on your money, you are trying to work every engine for every related keyword. Now think of the keywords that you could be going for in all the worlds’ languages!

    Do a bit of research in some of the common languages. If I was Italian and new to the net, the first place I would be searching is in an Italian search engine. Go to http://arianna.iol.it/ and search using the word porn and you will find 10 listings come up all in Italian. Not one is English. Even http://it.yahoo.com/ Yahoo Italia does NOT serve up your English porn site in its results.

    So how do you get a piece of this pizza pie? You need at least a doorway written in Italian. You need to visit a site like http://www.adult-site-translation.com/ and find out how affordable it is for a doorway page that is put together by a foreign translator. Not only is the text for your doorway sites or even complete tours with the proper keywords but the graphics are redone where necessary. You really cannot rely on a text translator. We all have been on a site where it was obvious that the webmasters first language was NOT English and felt bad for their awkward use of words. This is not how to make a sale.

    You need to be careful that you choose a professional service for your translating needs. You need to know that the translators are top notch and can not only translate your existing page/site keeping your marketing angles but they can also advise you on such things as proper wording and what a surfer from that culture would find erotic. Languages do not translate word for word. A service like Adult Site Translation has hired translators who also know how to market adult sites. They will tell you the search terms your page should be listed under and can assist you with foreign search engine optimization.

    Remember the days where you were the only site in a category or niche? It was like being a pioneer and it was very lucrative. Do you want to be first to market to these growing pockets of millions of new surfers? There are new frontiers out there and finally sites like Adult Site Translation can assist you to conquer them successfully!

    Article written by Susanna

  • JavaScript Know How

    Date: 2011.02.22 | Category: Scripts | Response: 0

    JavaScript can be one of the most useful additions to any web page. It comes packaged as standard in Microsoft’s Internet Explorer and, Netscape Navigator and allows webmasters to perform field validations, mouse-over’s, pop ups and a whole entourage of other nifty little features on our sites.

    In this article we will show you how to:

    – Display the browser name and version number
    – Change the text in the status bar of the browser
    – Use an input box to get text from the user
    – Use a message box to display text to the user
    – Change the title of the browser window

    Before that, however, we need to know how to setup our web page so that it can run the JavaScript. JavaScript code is inserted between opening and closing script tags: <script> and </script>, like this:

    <script language=”JavaScript”>

    –> JavaScript code goes here <–

    </script>

    These script tags can be placed anywhere on the page, however, it’s common practice to place them between the <head>and </head> tags. A basic HTML page that contains some JavaScript looks like this:

    <html>
    <head>
    <title> My Test Page </title>
    <script language=”JavaScript”>

    function testfunc()
    {
    var x = 1;
    }

    </script>
    </head>
    <body>
    <h1>Hello</h1>
    </body>
    </html>

    For the examples in this article, you should use the basic document format I have just shown you, inserting the JavaScript code between the <script> and </script>tags. When you load the page in your browser, the JavaScript code will be executed automatically.

    Displaying the browsers name and version number.

    The “navigator” object in JavaScript contains the details of the user’s browser, including its name and version number. They can be displayed in a browser using the document.write function:

    document.write(“Your browser is: ” + navigator.appName);
    document.write(“<br>Its version is: ” + navigator.appVersion);

    I run Windows 2000 and Internet Explorer version 6, so the output from the code above looks like this in my browser window:

    Your browser is: Microsoft Internet Explorer
    Its version is: 4.0 (compatible; MSIE 6.0b; Windows NT 5.0)

    Changing the text in the status bar of the browser.

    To change the text in the status bar of a browser window, just change the “status” member of the “window” object, which represents the entire browser window:

    window.status = “This is some text”;

    Using an input box to get text from the user.

    Just like in traditional windows applications, you can use an input box to get some text input from the user. The “prompt” function is all you need:

    var name = prompt(“What is your name?”);
    document.write(“Hello ” + name);

    The prompt function accepts just one argument (the title of the input box), and returns the value entered into the text box. In the example above, you get the users name and store it in the “name” variable. You then use the “document.write” function to output their name into the browser window.

    Using a message box to display text to the user.

    You can display a message box containing an OK button. These are great when you want to let the user know what is happening during their time on a particular page. You can use a message box to display the “name” variable from our previous example:

    var name = prompt(“What is your name?”);
    alert(“Your name is: ” + name);

    The “alert” function takes one argument, which is the text to display inside of the message box.

    Changing the title of the browser window.

    To change the title of a web browser’s window, simply modify the “document.title” variable, like this:

    document.title = “My new title”;

    One bad thing about the “document.title” variable is that it can only be manipulated in Microsoft Internet Explorer. Netscape’s implementation of JavaScript doesn’t allow for modification.

    In Closing.

    As you can see from the examples in this article, JavaScript is a powerful scripting language that can be used to enhance a visitor’s experience with our site. However, you shouldn’t use JavaScript too much because in some cases it can annoy visitors and send them packing before your site even loads!

    Article Written By Lee

Premium Sponsors















Categories

Site Links