Is there a way to find the browser window height and width in VB.Net without having using javascript? - vb.net

I am needing to get the browser height and width of the browser window with vb. I can get these values by setting an ASP.Net hidden input control using javascript, after the page has loaded and a post back is done. I need to be able to get these values when the page initially loads so I can create an image based on those values.
I am still new at VB.Net, so any help would be great. Thanks!

Quick answer: No, you cannot.
BUT: You may have access to those values by looking at the request headers values.
Please note that the value may not always be there and that different browser may or may not sent those values with different keys.
The best way to have this value should be usign javascript or vbscript (ie CLIENT script). You may use ajax you create your image async way.
ASP.NET is a SERVER side programming language (like JSP or PHP) and has nothing to do with which browser access it...
Look at it this way, what is the screen size of Google Bot "browser" ? Or what if a access your site with telnet ?
So you should use client script to have acces to client properties.
Do not hesitate to comment if I am not clear or right.

Related

Modifying photosphere on website thing

What i am trying to do is to use a photosphere on my website so that it shows up on full screen as a website cover page. The problem is the the code to embed a photosphere in a webpage given here by google
https://developers.google.com/photo-sphere/web/
lets only the photosphere size to be hardcoded as
displaysize="600,400"
what ever the values but its still hardcoded. What i want is that it gets adjusted to the screen of the user and gets displayed in the whole browser window. Any one got an idea how to pull it off? I didn't find any stuff about 'photosphere on web' other than the google link i gave above.
Indeed the API is currently designed to take static values. I think it's a good point that users might want to set the dimensions to 100% and let it resize dynamically.
I put it on the TODO list and will try to get to it shortly.
In the meantime, one work around is the following: After the viewer loads you will find an iframe on the page which contains it. You can change it's dimensions dynamically to your liking and the viewer should adapt.
The API provided by Google wraps the whole photosphere in layers of iFrames.
You can use the API to request a certain photosphere but only use the response to parse it for the values you need. Then you create your own request and the result can be shown fullscreen.
An example link is this
I created this link dynamically from the JSON response from the elements
media$group media$content 0 url
Hope it helps.
Can't you take the raw image and just use webgl to project it on the inside of a sphere?

Find a link inside iframe in webbrowser control in VB.net

I want to find a url webbrowser control inside iframe.
1) my webbrowsercontrol opena url
2)that url has one iframe inside it
3) That Iframe has a link which I want to grab programmatically using vb.net
At any point of time use webBrowser1.Url.ToString() to get the URL of the current open link.
You can get the html code of the open url by using webBrowser1.DocumentText. Once you have the html code use string manipulation to find the "iframe src" value.
This can be abit complicated as you migt not know how may iframes you need to handle.
As well there are some limitations for the FRAME elements according to HtmlWindow.WindowFrameElement Property
You cannot access a FRAME elements or the FRAME's document if the
FRAME is in a different zone than the FRAMESET that contains it. For a
full explanation, see About Cross-Frame Scripting and Security.
Actually, all you need to do is this...
Msgbox Webbrowser1.document.frames(0),getelementbyid("linkTagId").href
This will show you the href of the link, don't bother wasting time with string manipulation.
Of course, you can loop through the frames and links as well using the .length properties in a for loop.
Also, there are ways to bypass the cross-frame security issues since you are running the code in an exe, there are examples online, just search for "bypass cross-frame security webbrowser control" in google without the quotes.
If you need more help with these let me know as I can tell you how. Remember the cross frame stuff only need bypassing if the parent domain name and iframe domain name are different (not subdomains though, they can be different no problems).
Let me know mate :)

How do I get a Captcha off a website and display it in a picturebox using VB.NET?

In Visual Basic .NET is there a way to access a website/signup page and then get the Captcha and load it into a picturebox? How would I do it?
From your question, I can't tell if you are looking for a captcha plug-in or use a plug-in from another site. If you're looking for a plugin, try Recaptcha.
UPDATE
Trying to pull a the captcha image off of a site could be done in two ways, but it the captcha rotation were done correctly, it would no do you any good to be able to pull it off.
One way would be to just right-click on the image and reference that URL in your code. However, as stated previously, this would not be that reliable. The service that generates the image would rotate, and the image URL would be different on every refresh. In other words, the copied URL would only be good for the one time you copied/captured it via right-click or whatever. If the URL did not rotate, then that would be a security issue for the site which is why the image source is different on each refresh.
Another way would be to make a direct request to the page, scrape the content for the captcha image's source, and pull the source from the parsed content. The code for this would be fairly specific per page, and, with my limited knowledge, I can't think of a way to make a generic application to do so.
I don't know why you would want to do what you are wanting to do, unless this is a homework assignment, or you are up to no good.
Depends on the captcha service the website uses.
If the site uses reCAPTCHA, you would probably need to look for the image tag that has id "recaptcha_challenge_image" and display that image tag in a web browser control.
Here is the demo page I found: http://www.google.com/recaptcha/demo/. If the captcha itself is in a frame (or iframe), you will need to check the code in the frame itself.

POST a HTML Form programmatically?

I need to POST a HTML form to a 3rd party website (a Mass-SMS texting system).
In the past I've done this by forwarding to a page containing a form I've pre-populated and hidden (using display:none), then I've ran a javascript function at the end of the page to automatically submit this form.
However I'm hoping theres someway I can do all this programmatically (as I don't care about the response, and the user doesn't need to see the page the form is being posted to).
How can I do this? Cheers
You could use a WebClient.UploadValues method to send an HTTP POST request to a remote server from your code behind. Just fill up the name/value collection with the values coming from the hidden fields.
If you're willing to get into PHP, you can very easily use cURL for this.
Otherwise it's going to be quite difficult using just Javascript.
See here for a detailed tutorial.

How to load two websites in one page?

I don't want to use frame or iframe because most websites are busting it nowdays.
what are the possible methods to do this?
The intended behaviour is as if like two browser controls loaded in a website.
What is wrong with an iframe? What do you mean by busting (lots of websites are full of iframes)? You do not want to use iframes within an email but that is a different point!
The advantage is when people click on links within an iframe the content of the iframe gets refreshed, while if you pull the content of a webpage and then display it within a div the user will be moved on loosing the rest of the page.
you can pull it via script (PHP / curl) and display the code from there.
or you can use good old frames, although i wouldn't recommend it.
If you do not want frames, then another option is to do it server side - make your server access the pages and combine them into one response stream.
You can also so this client side using Javascript and DHTML
fopen() returns a file pointer:
$file = fopen("http://www.site.com/", "r");