Question

implement a program that reads a word and opens one of the following web pages based...

implement a program that reads a word and opens one of the following web pages based on the word provided: (name it file 1.html)


Word                Site

Twitter              twitter web site

Facebook         Facebook web site

yahoo               yahoo web site


If the provided word is not part of the above table, your program will open a page called error.html. The error.html page is a page you will define that will display the message "We cannot process your request". Use the <h1> </h1> tags to display the message and include a picture that you like indicating a failure occurred. Using window.open to open a web site (e.g., window.open("http://www.google.com/");).

(name it file 2.html) implement a program that reads a word and a search engine name (either google or bing). If an invalid search engine name is provided, display the message "Invalid engine" using alert. If a valid engine name is provided, perform a search using the specified search engine. To search using google append the word to search to the end of the string https://www.google.com/search?q= and use window.open with the resulting string. To search using bing, follow a similar approach using https://search.bing.com/search?p=

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1.html code:-

<html>
   <head>
   <title>Redirector</title>
  
   </head>
   <body>
       <input type="text" id="word"></input>
       <br>
       <button onclick="redir()">submit</button>
      
   <script>
       function redir()
       {
          
           arr = ["twitter","facebook","yahoo"];
           var word = document.getElementById("word").value;
          
           if (arr.indexOf(word) >= 0)                                  <!-- for checking word exists in list or not -->
           {
               if (word=="twitter")
               {
                   window.open("https://www.twitter.com");
               }
               else if(word =="facebook")
               {
                   window.open("https://www.facebook.com");
               }
               else if(word == "yahoo")
               {
                   window.open("https://www.yahoo.com");
               }              
           }
           else
           {
               window.open('error.html');
           }
          
       }
   </script>
   </body>
  
</html>

2.html code:-

<html>
   <head>
   <title>Redirector</title>
  
   </head>
   <body>

        <p>word:- </p>
       <input type="text" id="word"></input>
       <br>

        <p>engine:- </p>
       <input type="text" id="engine"></input>
       <br>
       <button onclick="redir()">submit</button>
      
   <script>
       function redir()
       {
          
           arr = ["google","bingo"];
           var word = document.getElementById("word").value;
           var eng = document.getElementById("engine").value;
          
          
           if (arr.indexOf(eng) >= 0)
           {
               if (eng=="google")
               {
                   window.open("https://www.google.com/search?q="+word);
               }
               if(eng == "bingo")
               {
                   window.open("https://www.bingo.com/search?p="+word);
               }
           }
           else
           {
               window.write("Invalid engine");
           }
          
       }
   </script>
   </body>
  
</html>

output1:-

output2:-

Add a comment
Know the answer?
Add Answer to:
implement a program that reads a word and opens one of the following web pages based...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program, called wordcount.c, that reads one word at a time from the standard input....

    Write a program, called wordcount.c, that reads one word at a time from the standard input. It keeps track of the words read and the number of occurrences of each word. When it encounters the end of input, it prints the most frequently occurring word and its count. The following screenshot shows the program in action: adminuser@adminuser-VirtualBox~/Desktop/HW8 $ wordCount This is a sample. Is is most frequent, although punctuation and capitals are treated as part of the word. this is...

  • Consider the following C++ program. It reads a sequence of strings from the user and uses...

    Consider the following C++ program. It reads a sequence of strings from the user and uses "rot13" encryption to generate output strings. Rot13 is an example of the "Caesar cipher" developed 2000 years ago by the Romans. Each letter is rotated 13 places forward to encrypt or decrypt a message. For more information see the rot13 wiki page. #include <iostream> #include <string> using namespace std; char rot13(char ch) { if ((ch >= 'a') && (ch <= 'z')) return char((13 +...

  • Instructions: Consider the following C++ program. It reads a sequence of strings from the user and...

    Instructions: Consider the following C++ program. It reads a sequence of strings from the user and uses "rot13" encryption to generate output strings. Rot13 is an example of the "Caesar cipher" developed 2000 years ago by the Romans. Each letter is rotated 13 places forward to encrypt or decrypt a message. For more information see the rot13 wiki page. #include <iostream> #include <string> using namespace std; char rot13(char ch) { if ((ch >= 'a') && (ch <= 'z')) return char((13...

  • Programming in C. Name this program schwifty.c - This program reads a text file and makes...

    Programming in C. Name this program schwifty.c - This program reads a text file and makes it schwifty, but the user determines the schwiftiness. The user supplies the filename to schwift and a string containing a sequence of the following characters to determine the schwiftiness via command line arguments: L - Left shift each character in a word: hello --> elloh R - Right shift each character in a word: elloh --> hello I - Shift the letters' and digits'...

  • Could I get some help with the following Task? The program should be implemented in JavaScript and running on Firefox, a web browser independent to operating systems. The client has specified the foll...

    Could I get some help with the following Task? The program should be implemented in JavaScript and running on Firefox, a web browser independent to operating systems. The client has specified the following requirements for the functionality of the program: 1. The program should be running without errors throughout two Phases: Information Gathering and Information Presenting. 2. Information Gathering is to gather the information such as state/territory name, the population and population change over previous year for calculation of APG;...

  • Description: Create a program called numstat.py that reads a series of integer numbers from a file...

    Description: Create a program called numstat.py that reads a series of integer numbers from a file and determines and displays the name of file, sum of numbers, count of numbers, average of numbers, maximum value, minimum value, and range of values. Purpose: The purpose of this challenge is to provide experience working with numerical data in a file and generating summary information. Requirements: Create a program called numstat.py that reads a series of integer numbers from a file and determines...

  • Question - What's next for Google? Is the company right to put so much focus on...

    Question - What's next for Google? Is the company right to put so much focus on Mobile? GOOGLE In 1998, two Stanford University PhD students, Larry Page and Sergey Brin, founded a search engine company and named it Google. The name plays on the number googol-1 followed by 100 zeroes—and refers to the massive quantity of data available online that the company helps users find. Google's corporate mission is "To organize the world's information and make it universally accessible and...

  • Questions 1. With a portfolio as diverse as Google's, what are the company's core brand values?...

    Questions 1. With a portfolio as diverse as Google's, what are the company's core brand values? GOOGLE In 1998, two Stanford University PhD students, Larry Page and Sergey Brin, founded a search engine company and named it Google. The name plays on the number googol-1 followed by 100 zeroes—and refers to the massive quantity of data available online that the company helps users find. Google's corporate mission is "To organize the world's information and make it universally accessible and useful."...

  • Design an original, professional web site following the specifications listed below. This web sit...

    Design an original, professional web site following the specifications listed below. This web site will be for a business you plan to set up for yourself or for someone else. The following is a detailed list of the requirements for your web site. READ them carefully. Instructions - Web Site Requirements for the web site: General: You will thoroughly test all your pages in more than one browser. All links MUST work. All graphics must show on the page. All...

  • This program will store a roster of most popular videos with kittens. The roster can include...

    This program will store a roster of most popular videos with kittens. The roster can include at most 10 kittens.You will implement structures to handle kitten information. You will also use functions to manipulate the structure. (1) Create a structure kitten. The structure should contain the following attributes: name; string color; string score; integer Important! The name of the structure and each of its field must match exactly for the program to work and be graded correctly. (2) Create a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT