Where does this style information come from - java

I am debugging a web portal out of a Java project. In the resulting jsp page, a div is always not shown, the reason is because there is a "display:none" being set for it:
<div class="settings_nav" style="display: none;">
</div>
In the debug mode of the Chrome browser, there is a "Styles" section describes this as:
element.style {
display: none;
}
Interestingly, this style information is not associated with any CSS stylesheets in Chrome debug mode, I searched through the CSS stylesheet set, there is still not hit.
Could experts give me some hint on where is the best place to find this style definition? Thanks.

It's not coming from a style sheet since it's an inline style on the div.
Inline styles override values from style sheets.
Could have been added through JavaScript or server side code

element.style refers to dynamically added styles; that is, as others have pointed out, added by javascript. I would look through your js files. Your best bet is to search your js directory for keywords that are involved in changing CSS. I can almost guarantee that the word 'display' is used somewhere (unless you are using jquery) and if you are really lucky maybe you'll only get a couple hits on that search term.

There are a few different ways in which you might see the styles applied and you can check it through the dev tools.
Inline style
User-agent stylesheet
Styles defined in a stylesheet
Using Javascript

Related

Can you make JEditorPanes understand advanced HTML and CSS?

Is it possible to make a JEditorPane understand more advanced HTML and CSS?
I mean, when you enter HTML or CSS such as <button>, <progress>, or most other tags, it does not understand them. Is there any way to make it understand and display more complex and advanced coding? If it is, how would I do it?
Thanks!
Yes. Java 7 EE has HTML5 functionality although I'm not sure about specific tags. Also, there are external packages, like one from Intel freely available and you can always extend the functionality yourself in some way or another.
Edit: addendum to my 2nd suggestion (implementing the topic in the linked question)
The Intel JWebEngine (which might be what you are already looking for) documentation says:
What are the advantages versus the built-in Java HTML editor?
The built-in Java HTML editor of Java is very limited. It only
supports HTML 3.2 with some features of HTML 4 and CSS. The support of
CSS is wrong in many cases, especially when it comes to cascading
selectors. The text is often too small and on many web sites Java only
shows an error instead of a incorrectly formatted page.
Here are some further differences:
JWebEngine can display the ACID 1 test correctly - Java does not
JWebEngine can display the ACID 2 test partly - Java only displays a
blank page because an error occurs
JWebEngine basically shows HTML pages like a browser with JavaScript disabled
In cases where the CSS
and HTML specifications are not explicit about implementation
JWebEngine is designed to mirror Mozilla FireFox's behavior.
No it just understands basic HTML 4.
You could use a JavaFx WebView inside a JFXPanel

Firebug kind of library/control (php/java/.net) to use in my application

Is there any PHP/.NET/Java library that I can use in my application to get final CSS styles applied to elements of a web page (after css and js are executed). For example I want to get text color of the <p class="summary"> in a loaded HTML page.
Is there a firebug kind of library/control (php/java/.net) to use in my application. No UI is neccessary though.
Essentially, you need a web browser for this. You may want to look into embedding options of web browsers (UI-less, I guess), or you could go the easy route and implement it as e.g. a Chrome or Firefox extension right away; essentially running inside the browser and having the browser do all the parsing and CSS work for you.

jsp, can't find source of css property

This may be a tricky question because I can't give much detail,
I'm working of legacy code on a big project (in jsp) and I came across a "styleid = product".
It changes quite a lot of things when I remove it, but I can't seem to find it in any of the CSS files, there are properties like "tdproduct" and "thproduct" but I can't seem to find any connection.
Can anyone give me an indication of other places I might need to look for this (except .css files).
thanks in advance
Can you load the page in firefox/chrome browser?
If so you can see the generated source code.
Since JSP is a server side technology that generates some dynamic content, its also possible that the CSS will be also generated dynamically.
Theoretically it can be JSP itself, the CSS and even Java Script :)
Good luck!
Hope this helps
css are dynamically loaded when your page is loaded. your style classes can also be defined in the jsp that you are including in the parent jsp.
open the page in firefox and use firebug to view the styles loaded. You can locate where your style is loading from.

mediawiki syntax parser for android

I need some help fetching the content of a mediawiki page and displaying it in my android app. I've found that mediawiki has a api which can export the markup text, but I need someway to parse it.
Other solutions are also welcome, but I don't just want to include the whole page (with menus and everything) as a webview.
You can get the HTML for just the content section (i.e. not including the menus and everything) by specifying action=render when fetching the page normally. You can get about the same result using the API's action=parse. In either case, you could then supply your own framing HTML, stylesheets, and the like for proper display to the user.
If you are in control of the wiki you may be best served by using the mobile format that wikipedia uses. Otherwise it will depend on what the markup text it returns looks like. If the markup is what you would see in the wiki editor you may have issues. Wikipedia for example make extensive use of templates (or whatever they call them). I'm not sure if you can do much if you don't have the actual temple code behind that.
You also might want to look at http://www.mediawiki.org/wiki/Markup_spec if you are headed down this path.

Is there a way to change or reskin an incoming website on the fly?

I have a project where they want me to embed a website into a java application and they want the website to have a similar color scheme as the rest of the application. I know a lot about CSS and building websites but I am not aware of a way to change the look of a website as it comes in on the fly. Is there someone who can help?
Update:
I don't have access to the header because it is not my website. To give more info about the project is we have a browser embedded in a java client application. The user needs to access a website that displays the contents of a database. I have no access to the original html or css from the site.
What i need is to change the background color and font sizes of the incoming webpage to match the look and feel of the java application.
One approach would be to replace their CSS with your own.
You could also take the approach used by the Stylish plugin, which involves a lot !important decelerations to override the site's CSS. Since this is a Java app, I assume the user will not have opportunity to supply their own CSS, so using !important here doesn't precisely go against the standard.
In your particular situation, I'd look into data scraping, all you need to do is scrape the website for the data, and then re-style it to present it how you want.
Good luck
The Greasemonkey add-on for Firefox does just this. You can write a bit of Javascript code and have it run when certain web pages load. One common thing to use it for is to make changes to the DOM to move page elements around, hide or resize elements, change colors, etc. There are a bunch of examples at userscripts.org if you want to get an idea of what I am talking about.
Your code would simply need to do something similar. Load the page (including the normal style sheets) and then use the DOM to make changes to style elements as desired. Browse through the source of the page to get the names/ids of important elements, and your code can key off of those. Loading an additional CSS file containing your changes is an option, but doing it programmatically will likely give you more flexibility in the event that the target website changes.
Depends on what do you use to show the pages in Java. Most browser implementations support dynamic changes to the DOM, so you can simply add a CSS file to header as a last element, and it will be applied.
you need to know the markup of the html / css so you can make the best skin.
you could theoretically do it by styling just the basic tags: h1...h6, p, etc... but it would not be as good and would probably fail to produce the best results at times and even produce horrible things at times.
if you KNOW the site markup then you can make a skin and simply use CSS/images to skin it as you wanted it.
just include your CSS markup LAST so that it overrides the one already present on the site that you want to skin differently.
should not be a difficult thing per se. the skin itself is probably the better (more effort required) part of the job.
On the fly, should mean changing the html fetched. So parsing and replacing tokens seems to be a/the way.
You could change the locations of the style sheet files by replacing the href value in a link that points to a css file, and set the value to your style sheet (a different URI).
<link type="text/css" href="mylocalURI" rel="stylesheet />
(this should be the result of a process/replacement)
I think you understand what should happend for inline styles.
I would use JTidy to normalize the original site HTML to XHTML, then use XSLT to filter only the interesting/relevant information, obtaining XML format; and finally (since I wouln't want to convert XML to objects), XSLT again to transform the "pure" XML into the HTML look & feel I need/want.
All of this can be assembled as streams, using more or less 4 Kb of buffer per filter (12 Kb total) per thread. Also meaning that it will run fast enough. And all built on standard, open-source available components.
Cheers.

Categories

Resources