Gecko WebBrowser, getting the url from a selected hyperlink - visual-studio-2010

This is a real 2%er but here goes, I have created a winform in VS2010 with Gecko 2.0.1-0.10 (latest release) webbrowser control, I am using a touch screen to navigate. Sometimes when clicking a hyperlink it will select text rather than navigate, on the DomMouseUp event I want to check to see if there is selected text, if so I want to see if it is a hyperlink and if it is, where that hyperlink goes to. I had a mess around with GeckoSelection but nothing looked obvious. I am looking for a way to see if what is selected within the web browser is a hyperlink, any thoughts?

I've worked it out : for anyone interested in such things, use DomFocus on the gecko control:
m_strInnerHtml = geckSel.ActiveElement.Parent.InnerHtml.ToString();
That will give you the innerhtml of the selected item, from here you can extract the href tag and get the url, navigate to it, hey presto :)

Update: An even better solution is to use (in DomFocus again)
m_strInnerHtml = geckoWebBrowser.Document.ActiveElement.GetAttribute("href");
This will return the actual hyperlink address, one thing to watch out for however is if you're on google for example and select the "Advertising" hyperlink at the bottom of the page, it may return "/advertisingpage/" which must be appended to the original url. Clicking a hyperlink away from google will return the full address however.

Very good behavior gives this call:
m_strInnerHtml = geckoWebBrowser1.Url.AbsoluteUri()

Related

How to disable firefox's reader view from my website?

Today i updated my firefox to the latest version and one big feature is the reader view for desktop. We launched a webshop two weeks ago and now there is this tiny "reader view" icon. When i click on it i get an error-message. My team-leader wants me to remove this feature when visiting this site.
is it possible to remove or hide the "reader view" feature from firefox when visiting my site?
There is currently no legit way of disabling Reader View for your website. Reader View is supposed to automatically detect on what pages it should be available and on what pages it should not.
If there is an issue with your website, your best option is probably to report it there: https://github.com/mozilla/readability/issues
You can also find more info about the issues affecting Reader View in Firefox there: https://wiki.mozilla.org/QA/Reader_view
Although I would not recommend it, there might be a way to fool Reader View into thinking it should not parse your website, if you really need to. A quick look at the source code reveals that it will not parse certain type of documents, certain URIs and malformed URLs. You would need to dig in the source to understand how/if your site can safely be adapted to avoid being parsed. The Reader View source code can be found here: https://mxr.mozilla.org/mozilla-release/source/toolkit/components/reader/ReaderMode.jsm or
https://dxr.mozilla.org/mozilla-release/source/toolkit/components/reader/ReaderMode.jsm
This Question shows how to Optimize website to show reader view in Firefox. So you have to ensure that your site is not optimized for the Reader View.
Don't use formatting options that are favoured for the Reader View and so on.
I guess this will suffice:
Don't use the <p> Tag
write all Textblocks in small portions
Here are some more details about the mechanism
Replace p tags with div tags in your page. It worked for me, even when I have div tags with pre tags (preformatted text) on the same page.
There is no way of forcing disabling the Reader View to the user, But if it is important to your site, you can notify the user to disable or not use the reader feature of firefox.
This would be the way to Disable the Reader on the users browser
in the Enter about:config in browser address bar
click the "I'll be careful I promise" box
search for reader.parse-on-load.enabled
toggle preference to false (right click > toggle to false )
close the about:config page > refresh browser > reader view icon has gone
put this code on your css code and you are done !
/* CSS Reset */
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,
p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,
img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,
dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,
thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,
footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,
audio,video,adnav,adheader{
margin:0;
padding:0;
border:0;
font-size:100%;
font:inherit;
vertical-align:baseline;
}

Display of object class in page frame for visual foxpro 6

I've bundle of control save in .vcx file but I need to activate it to display it when i switch to different activepage in pageframe.
Could anyone guide me how to code and which kinds of event should i make on page frame switch, click or whatelse UIENABLEEVENT.
Thanks.
First, you might want to click on Help -> Tour for site etiquette and start voting / checking your answers so people know what worked or not that help you and others with similar issues.
Now, back to you question... If you have a form with a pageframe, make sure you have the "Properties" sheet open, it helps to ensure which object you are actually working with until you get more familiar with the IDE.
Once you click on the pageframe control, if you right-click and then select "Edit", that will bring you to the individual PAGE level of the pageframe. Once the PAGE is the basis of the focus you can put any control on it from either the toolbar, or if your project is open and you expand your .VCX class library, you can grab any control and put in on the page.
If you have multiple pages, once you click on the alternate pages, you will see that the first page (or whatever page) is no longer visible and the new page is available for you.
The actual handling of the pages on the pageframe for clicking / focus is automatically handled for you unless you want to do something extra.

Displaying a .pdf in WebBroser WP7

I have an application which has a listbox. When an item in the list is clicked the app takes us to a new page with a web browser which displays the contents of that particular item (we get these from a particular list which is previously parsed xml data) in a web browser (because they also contain html elements). This all works perfectly fine.
Now, there are a few items in the list which contain a link. The link displays in the browser and when clicked it takes us to a .pdf file (still in the webbrowser) which is not being displayed.
What I now wonder is:
How to check if the link is being clicked? Is there an event for that?
How can I display the .pdf within the webbrowser control without the aid of other application?
Thank you,
Should you need any code that's currently working and written just ask.
To know if the link is clicked, you can use the Navigating event of the webbrowser.
Unfortunately, you can't use the webbrowser to display the PDF. You'll have to use a WebBrowserTask instead.
To sum it up, in your case you can use the Navigating event to detect the click on the link (since it's apparently important from you), then cancel the navigation (by setting e.Cancel = true in the event handler), then call the WebBrowserTask to display the PDF document.

Remove "componentheading" from homepage - Joomla!

I'm working on a site in Joomla! and on the homepage, at the top of the article, it comes up with a h1 of the website name. The pagesource says (Note it's not the article title.)
Any idea how to get rid of it?
Thanks,
Steph
You can set this h1 tag not to display via the Parameters - System section of your Menu Item Manager screen in administrator ... this page has a nice depiction of the steps.
It's so simple
Just do the following :
Login to the Joomla Administrator Interface
Go to the Menu Manager
Select your Menu
Select your Menu Item (Home Menu)
On the right hand, Click Parameters (System)—> and in the *Show Page Title—->*Just Select No.
That's all.
This is not the desired solution, since many people, (including myself) actually need to be able to Set/Override the page title (That Appears in the Browser’s Title bar), and setting Page Title to no here will also remove the functionality to Configure the Browser title (which is important for SEO among other things).
Anyway, I have searched and not been able to find a fully correct solution via CMS or PHP Code. The closest solution which is not fully perfect, but unlikely to cause significant (if any) negative effect on your site is through Javascript (Example is JQuery).
jQuery(document).ready( function($) {
$(‘.componentheading’).empty();
});
This can also be done is JS with no JQuery. When I find a better method of doing this I’ll let you know.This should actually be done by removing output from a template file.I don’t know which one yet. When I do, I’ll post it…
When setting the page title not to show in the menu item as stated in other answers, this will not stop the text entered in the page title box being used as the browser title, it will just stop it being shown in the page.
Using javascript to remove it is not a good idea.
1. It will only work for browsers with javascript enabled
2. Search engine spiders will still see it. As the component heading for articles is 'articles' by default it will see all your pages with the same h1 tag.
Just turn it off in the menu item and enter your browser title in the text box above.

Manipulate Html from Firefox Extension

I am creating a Firefox extension that is somewhat similar to Firebug. There is a panel (or vbox) at the bottom of the browser that allows users to specify colors to certain Html elements. When they click the OK button, I would like these colors to get updated on the current web page.
I have my JavaScript working when I click the button (i am just throwing an alert), however when I change that JavaScript to change the css or styles of an element (by either using document.getElementById or jquery), nothing changes.
Is there something with Firefox extensions that I am missing? Any help is appreciated.
Let me know if you have any questions. Thanks
https://developer.mozilla.org/en/Extension_Frequently_Asked_Questions#Accessing_the_document_of_a_webpage_doesn%27t_work
You want content.document.getElementById() and similarly for every other construct you use.

Resources