Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Get Weather" Button Redirects to a Blank Page Instead of Showing Weather Results #44

Open
1 task done
Shreyhac opened this issue Oct 15, 2024 · 1 comment
Open
1 task done
Assignees
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest Issues for Hacktoberfest

Comments

@Shreyhac
Copy link

Has this bug been raised before?

  • I have checked "open" AND "closed" issues and this is not a duplicate

Description

When entering a location in the "Weather" input field and pressing Enter or clicking "Get Weather," the page currently redirects to a new, blank page without displaying any weather information.
Current Behavior:

Enter location in the weather input field.
Press Enter or click "Get Weather."
The system redirects to a blank page, with no weather data being displayed.
Proposed Solutions:

Redirect to a Weather Source (e.g., Google Weather):
Upon pressing Enter or clicking the "Get Weather" button, the user should be redirected to Google Weather (or any weather service) for the entered location.

Example URL format for redirection:
https://www.google.com/search?q=weather+

Steps to Reproduce

Open the weather widget.
Enter any location (e.g., "New York").
Press Enter or click "Get Weather."
The result is a redirect to a blank page.

Screenshots

Screenshot 2024-10-16 at 01 35 34
Screenshot 2024-10-16 at 01 35 25

Do you want to work on this issue?

Yes

If "yes" to above, please explain how you would technically implement this

To implement this technically, I can handle the issue by either redirecting the user to a weather search result on Google or displaying weather data directly on my page using a weather API like OpenWeather. Here’s how I can do both methods:

Option 1: Redirect to Google Weather
Steps:
HTML Form: I likely already have a form for the weather input and the button.
JavaScript for Redirect: I can add a submit event listener to the form. When the user clicks "Get Weather" or presses Enter, the JavaScript will trigger a redirect to a Google search with the weather query.
Code Implementation:
Modify My HTML (if needed):

How it works:
The submit event listener captures the form submission.
It prevents the default behavior, grabs the location entered, and constructs a Google search query with the location.
Then, it redirects the browser to the Google search page using window.location.href.

Option 2: Display Weather on the Same Page Using OpenWeather API
If I want to display the weather directly on the page without redirecting to Google, I can use the OpenWeather API (or any weather API). Here’s a step-by-step approach to implement it:

Steps:
Get an API Key from OpenWeather.
Modify My HTML to show weather results.
JavaScript for Fetching Weather Data using the API.

@Shreyhac Shreyhac added the bug Something isn't working label Oct 15, 2024
@mohitahlawat2001
Copy link
Owner

i assigned it to you

make sure you star repo ⭐ and follow on github , giving hacktoberfest tag after this step

@mohitahlawat2001 mohitahlawat2001 added good first issue Good for newcomers hacktoberfest Issues for Hacktoberfest labels Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest Issues for Hacktoberfest
Projects
None yet
Development

No branches or pull requests

2 participants