how to use other page data to new page in jS
To use data from one page in JavaScript on a new page in Objective-C, you can pass the data as a query parameter in the URL. Here's an example of how you can achieve this:
NSString *dataToSend = @"Hello World";
NSString *encodedData = [dataToSend stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *urlString = [NSString stringWithFormat:@"https://example.com/newPage.html?data=%@", encodedData];
NSURL *url = [NSURL URLWithString:urlString];
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
On the new page, you can retrieve the data using JavaScript by accessing the URL parameters. Here's an example of how you can do that:
function getDataFromURL() {
const urlParams = new URLSearchParams(window.location.search);
const data = urlParams.get('data');
return data;
}
const receivedData = getDataFromURL();
console.log(receivedData);
Please note that this code assumes you are using a web view to display the new page. If you are using a different approach, the implementation may vary.