Skip to content
Advertisement

How can I display the object property in text format inside the another index.html webpage in Javascript instead of an URL?

Below there is a function I wrote to get Movies images and I hyperlinked those images with the Trending_movie.overview property.
When I click on the image I get the below-mentioned error ,the Function is converting the property Trending_movie.overview into somekind of URL

The Error is :-
Cannot GET /A%20group%20of%20vigilantes%20known%20informally%20as%20%E2%80%9CThe%20Boys%E2%80%9D%20set%20out%20to%20take%20down%20corrupt%20superheroes%20with%20no%20more%20than%20blue-collar%20grit%20and%20a%20willingness%20to%20fight%20dirty.

JavaScript

The Object is given below:-

JavaScript

I want to display the overview property on the new webpage in the text format instead of the URL.
Any kind of help would be appreciated…

Advertisement

Answer

Set the overview property to the href value of the anchor element. Then set the href to your index2.html and add ?id= after it. The value after the = should be the id of the Trending_movie.

JavaScript

Then on your index2.html you get the id of the movie that you want to show from the URL. There create a new script file where you will read the id and loop through your Trending movies.

The find method on the trending movies array will help you retrieve a single object from the array that matches the id.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement