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
  • Using Visual Studio 2017 Create This Program Using C# implement source code Program 5: The concept...

    Using Visual Studio 2017 Create This Program Using C# implement source code Program 5: The concept of a 5-digit palindrome number is a 5-digit number that reads the same from left to right and from right to left. For example, 12121, 45454, and 14741 are valid 5-digit palindrome numbers. Design (pseudocode) and implement (source code) a program (name it FiveDigitPalindrom) that reads a 5-digit number from the user (as integer value, not string) and then mathematically (using division and remainder...

  • Cipher Program Specifications: You are to write a program called, "Cipher123" that reads in an encoded...

    Cipher Program Specifications: You are to write a program called, "Cipher123" that reads in an encoded message using the 1-2-3 cipher and returns the decoded message. The program should continue prompting for additional encoded messages until the user chooses to quit the program. When decoding a message, we take the first letter of the first word, the second letter of the second word and the third letter of the third word and concatenate them. We repeat this same process 1-2-3...

  • 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."...

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