How to Change the HTML button size dynamically - javascript

I have a web browser in XAML:
<phone:WebBrowser x:Name="Browser" Grid.Row="1" Grid.RowSpan="2"
Navigating="Browser_Navigating"/>
It displays HTML content present in isolated storage so I retrieve the content and store it in a string to display it on WebBrowser,
Browser.NavigateToString(str);
The string contains a button which acts as a link. I want to change the size of this button.I do not know how to access the button present in string which is stored inside Isolated storage. Any idea?

There are more than just one way to get this done.
It's about string-manipulation.
Example 1:
Search through the HTML-String for the ID or Name of the Button.
If you found it: simply add style="font-size:99px" into the Buttons Tag, where the 99 is the size of it. Change it how you like to.
Example 2:
If you know that the CSS (Styling) is in the same Website (String) then you can edit or add the font-size attribute there.
After you did this, just call your edited String like this:
Browser.NavigateToString(EditedString);
If you've got questions, ask ;)

Related

How to change only part of the query in url

I have this url
http://www.test.com/home-package/?location=locationA&bed=3&bath=4
and a variable (e.g. $location = "locationB") which holds the value user has selected when they land on the website. They can also change this location from any page they want and the variable will be updated with that location.
What I'm trying to achieve is,
If user is browsing http://www.test.com/home-package/?location=locationA&bed=3&bath=4 and then change the location to 'locationB', I want the url to update to http://www.test.com/home-package/?location=locationB
Hope I have made this clear.
Edit 1: User is selecting location from a dropdown list. <select> is wrapped inside <form> and upon hitting save, the value of location is saved in a session variable.
Thanks.
As I understand the locationB is in HTML input element? Add a onchange listener to the element and redirect user with javascript.
let locationB = getValueFromElement();
window.location.replace("http://www.test.com/home-package/?location="+locationB);
//or
window.location.href = "http://www.test.com/home-package/?location="+locationB;
Read differences between JS redirects.
If the locationB value comes from backend and redirecting in backend is not possible you can also add a hidden element that holds the value and read it with JS.

Can i detect if a web page has been translated by Google?

I have a web page, in Dutch, with a poll with a radio button.
I'd like to know which language the users speak. Is there a way I can detect if the page has been translated by Google when they submit?
I do not use a translation bar, I am talking about the spontaneous google translation.
Just check a known element if the text matches your text.
function isDutch() {
return $('#readmore').text() === "Meer lezen";
}
or a non jQuery solution:
function isDutch() {
document.querySelector('#readmore').innerText === "Meer lezen";
}
Just make sure the element you have is an easy translatable sentence like read more.
Then you update a hidden field in your form with the result.
You can do this the moment a click is registered on your radio button.
I just tested it on a russian site, lenta.ru and ran $('a[href="/parts/news"]').text(); after having translated it by right clicking the page and selecting translate this page(chrome). The content returned was in my language(dutch) in the jquery text().
When translated through Google Translate, the target language is injected into the lang attribute of the main html tag, you can retrieve it with:
document.getElementsByTagName('html')[0].getAttribute('lang')
which results in something like
en-x-mtfrom-nl... and this in turn you can log to your server or set as a cookie.

ajax/json/? to query a webpage and return specifc div/p values

I'm trying to find code or a way to process the following:
When you click a button a site it'll go and read specific website link and then return variables that it finds in the remote page.
1) user clicks button
2) query goes to www.whatever.com/myfile.html
3) there is a specific p tag inside a div tag called 'totalamount' = <div id=WTextWrapper><p id="Amount">2,000</p></div> That I want to grab the value of and then display it on my page below the button that I clicked in step 1
I know there is a way to do it, but I have no idea how it's done.
You need to get the source of the html and use regex to extract what you need. You can use file_get_contents() function to get the source html.

how to append the element by id from different html pages in javascript

I am having one html page for recommendation.
In this page I have different buttons like choose contact, choose merchant. In choose merchant button, I have one textbox, after clicking on the button I will navigate to the page which contains the list of merchants.
After clicking on merchant name, that merchant name should displayed in textbox of recommend.html (first html page), but its not possible as the textbox id belongs to different html page and that merchant name id belongs to different html page.
I m able to append that merchant name to the same html page of choose merchant but can't append it to the recommend.html..anybody knows solution for this,..?
In a simple code example, using HTML5's session storage,
On your merchant list page, before bouncing back to the recommendation page, set the session storage item when the merchant is selected:
sessionStorage.setItem("selectedMerchant", "merchant_name");
On the recommendation page, read the item and display recommendations based on the selected merchant name:
var selectedMerchant = "";
if ( sessionStorage.getItem("selectedMerchant") ) {
selectedMerchant = sessionStorage.getItem("selectedMerchant");
}
Of course, you will need to handle various conditions, such as clearing the selected merchant names and validating the values, etc.
Check out the link below for more references:
https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage
You need to generate that html code and have to pass it in that page using jquery
For example if that element is like "#merchant" and generated html is like $("") then append it to selected element using insertAfter or appendTo
When you click on second.html (where ever merchant name exists), you need to submit a html form with action attribute to recommend.html and pass the merchant name as a hidden input type .
Then from second.html, you can access the POST parameters and display it in your text box.
Basically you need to have some server side coding (JSP/PHP/PERL etc)

pass data from popup gridview to parent page

the explanation given here http://wiki.asp.net/404.aspx?aspxerrorpath=/themes/fan/pages/page.aspx/282/passing-value-from-popup-window-to-parent-form39s-textbox/
is exactly what I want , but Its not giving the output and parent page despite doing exactly as explained ,
can anyone please send sample website with northwind data base ? no need of mdf file ,just a tested demo I will attach Northwind .
The task s simple , In pop up window there is a grid with some databound column and one with button , my task is when buton is clicked it must return text from respective grd row to the parent page'control (any)
Maybe is not working to you because on the sample is hard code the button id, and this logically because on the popup window did not know how the button have been render.
getElementById("ctl00_ContentPlaceHolder1_TextBox2")
So ether correct this id to make it as its appear to your page, ether make the control id on TextBox2 static so is not change, and get it by name.

Categories

Resources