Getting URL(URI) address from Web Browser
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am trying to get the URL string (uri) in the WebBrowser component after navigation, but the returned address is incomplete.
It should look like "https://oauth.vk.com/blank.html#access_token=..." but
e.Uri.AbsoluteUri
and all other fields return only "https://oauth.vk.com/blank.html" (image)
A line beyond the "#" is not returned. I navigate to the address in the browser, everything is displayed normally. I didn't find the answer to this question anywhere, I hope, here will help me.
I tried to get the URL in different ways but failed to get the full string.
Here's an code example:
browser.Navigate(getTokenUrl);
browser.Navigated += (sender, e) =>
{
MessageBox.Show(e.Uri.AbsoluteUri);
};
c# wpf file uri
add a comment |
I am trying to get the URL string (uri) in the WebBrowser component after navigation, but the returned address is incomplete.
It should look like "https://oauth.vk.com/blank.html#access_token=..." but
e.Uri.AbsoluteUri
and all other fields return only "https://oauth.vk.com/blank.html" (image)
A line beyond the "#" is not returned. I navigate to the address in the browser, everything is displayed normally. I didn't find the answer to this question anywhere, I hope, here will help me.
I tried to get the URL in different ways but failed to get the full string.
Here's an code example:
browser.Navigate(getTokenUrl);
browser.Navigated += (sender, e) =>
{
MessageBox.Show(e.Uri.AbsoluteUri);
};
c# wpf file uri
add a comment |
I am trying to get the URL string (uri) in the WebBrowser component after navigation, but the returned address is incomplete.
It should look like "https://oauth.vk.com/blank.html#access_token=..." but
e.Uri.AbsoluteUri
and all other fields return only "https://oauth.vk.com/blank.html" (image)
A line beyond the "#" is not returned. I navigate to the address in the browser, everything is displayed normally. I didn't find the answer to this question anywhere, I hope, here will help me.
I tried to get the URL in different ways but failed to get the full string.
Here's an code example:
browser.Navigate(getTokenUrl);
browser.Navigated += (sender, e) =>
{
MessageBox.Show(e.Uri.AbsoluteUri);
};
c# wpf file uri
I am trying to get the URL string (uri) in the WebBrowser component after navigation, but the returned address is incomplete.
It should look like "https://oauth.vk.com/blank.html#access_token=..." but
e.Uri.AbsoluteUri
and all other fields return only "https://oauth.vk.com/blank.html" (image)
A line beyond the "#" is not returned. I navigate to the address in the browser, everything is displayed normally. I didn't find the answer to this question anywhere, I hope, here will help me.
I tried to get the URL in different ways but failed to get the full string.
Here's an code example:
browser.Navigate(getTokenUrl);
browser.Navigated += (sender, e) =>
{
MessageBox.Show(e.Uri.AbsoluteUri);
};
c# wpf file uri
c# wpf file uri
asked Jan 3 at 20:54
KagaiKagai
1
1
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
JavaScript
Window.location.href will return all the url including hash part.
You can use apis to run this JavaScript in browser component and it should return you correct url.
The api to run JavaScript depends on browser component you are using.
Nope. Same problem. Code:var doc = (HTMLDocument)browser.Document; MessageBox.Show("RESULT: " + doc.parentWindow.location.href);
Result: image
– Kagai
Jan 3 at 21:36
I also tried using javascript codedoc.parentWindow.execScript("alert(document.location.href)");
directly, the result is the same.
– Kagai
Jan 3 at 21:44
1
Use window.location.href in JavaScript instead of document location. If that does not work the check if location.hash retuns the part after hash
– Manoj Choudhari
Jan 4 at 6:15
In the browser, the location.hash is returned correctly, but in the WebBrowser component hash is still empty
– Kagai
Jan 4 at 11:18
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54029669%2fgetting-urluri-address-from-web-browser%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
JavaScript
Window.location.href will return all the url including hash part.
You can use apis to run this JavaScript in browser component and it should return you correct url.
The api to run JavaScript depends on browser component you are using.
Nope. Same problem. Code:var doc = (HTMLDocument)browser.Document; MessageBox.Show("RESULT: " + doc.parentWindow.location.href);
Result: image
– Kagai
Jan 3 at 21:36
I also tried using javascript codedoc.parentWindow.execScript("alert(document.location.href)");
directly, the result is the same.
– Kagai
Jan 3 at 21:44
1
Use window.location.href in JavaScript instead of document location. If that does not work the check if location.hash retuns the part after hash
– Manoj Choudhari
Jan 4 at 6:15
In the browser, the location.hash is returned correctly, but in the WebBrowser component hash is still empty
– Kagai
Jan 4 at 11:18
add a comment |
JavaScript
Window.location.href will return all the url including hash part.
You can use apis to run this JavaScript in browser component and it should return you correct url.
The api to run JavaScript depends on browser component you are using.
Nope. Same problem. Code:var doc = (HTMLDocument)browser.Document; MessageBox.Show("RESULT: " + doc.parentWindow.location.href);
Result: image
– Kagai
Jan 3 at 21:36
I also tried using javascript codedoc.parentWindow.execScript("alert(document.location.href)");
directly, the result is the same.
– Kagai
Jan 3 at 21:44
1
Use window.location.href in JavaScript instead of document location. If that does not work the check if location.hash retuns the part after hash
– Manoj Choudhari
Jan 4 at 6:15
In the browser, the location.hash is returned correctly, but in the WebBrowser component hash is still empty
– Kagai
Jan 4 at 11:18
add a comment |
JavaScript
Window.location.href will return all the url including hash part.
You can use apis to run this JavaScript in browser component and it should return you correct url.
The api to run JavaScript depends on browser component you are using.
JavaScript
Window.location.href will return all the url including hash part.
You can use apis to run this JavaScript in browser component and it should return you correct url.
The api to run JavaScript depends on browser component you are using.
answered Jan 3 at 21:23
Manoj ChoudhariManoj Choudhari
2,4821722
2,4821722
Nope. Same problem. Code:var doc = (HTMLDocument)browser.Document; MessageBox.Show("RESULT: " + doc.parentWindow.location.href);
Result: image
– Kagai
Jan 3 at 21:36
I also tried using javascript codedoc.parentWindow.execScript("alert(document.location.href)");
directly, the result is the same.
– Kagai
Jan 3 at 21:44
1
Use window.location.href in JavaScript instead of document location. If that does not work the check if location.hash retuns the part after hash
– Manoj Choudhari
Jan 4 at 6:15
In the browser, the location.hash is returned correctly, but in the WebBrowser component hash is still empty
– Kagai
Jan 4 at 11:18
add a comment |
Nope. Same problem. Code:var doc = (HTMLDocument)browser.Document; MessageBox.Show("RESULT: " + doc.parentWindow.location.href);
Result: image
– Kagai
Jan 3 at 21:36
I also tried using javascript codedoc.parentWindow.execScript("alert(document.location.href)");
directly, the result is the same.
– Kagai
Jan 3 at 21:44
1
Use window.location.href in JavaScript instead of document location. If that does not work the check if location.hash retuns the part after hash
– Manoj Choudhari
Jan 4 at 6:15
In the browser, the location.hash is returned correctly, but in the WebBrowser component hash is still empty
– Kagai
Jan 4 at 11:18
Nope. Same problem. Code:
var doc = (HTMLDocument)browser.Document; MessageBox.Show("RESULT: " + doc.parentWindow.location.href);
Result: image– Kagai
Jan 3 at 21:36
Nope. Same problem. Code:
var doc = (HTMLDocument)browser.Document; MessageBox.Show("RESULT: " + doc.parentWindow.location.href);
Result: image– Kagai
Jan 3 at 21:36
I also tried using javascript code
doc.parentWindow.execScript("alert(document.location.href)");
directly, the result is the same.– Kagai
Jan 3 at 21:44
I also tried using javascript code
doc.parentWindow.execScript("alert(document.location.href)");
directly, the result is the same.– Kagai
Jan 3 at 21:44
1
1
Use window.location.href in JavaScript instead of document location. If that does not work the check if location.hash retuns the part after hash
– Manoj Choudhari
Jan 4 at 6:15
Use window.location.href in JavaScript instead of document location. If that does not work the check if location.hash retuns the part after hash
– Manoj Choudhari
Jan 4 at 6:15
In the browser, the location.hash is returned correctly, but in the WebBrowser component hash is still empty
– Kagai
Jan 4 at 11:18
In the browser, the location.hash is returned correctly, but in the WebBrowser component hash is still empty
– Kagai
Jan 4 at 11:18
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54029669%2fgetting-urluri-address-from-web-browser%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown