I'm studying the DOM and there is an explanation about dom here:
A web page is a document that can be either displayed in the browser window or as the HTML source. In both cases, it is the same document but the Document Object Model (DOM) representation allows it to be manipulated.
https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction
So can we have two different document on the same page?
According to W3 schools
When an HTML document is loaded into a web browser, it becomes a document object. The document object is the root node of the HTML document. The document object is a property of the window object.
In theory, we only have 1 document (it's under window object globally) to access the entire DOM within current HTML. In the DOM, we can have multiple elements/tags which you can manipulate via document
But document is created from DocumentHTML/Document.
The Document interface represents any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree.
Therefore, we can create a new one. Here is one example using new document injected into iframe
When do we need it? Well, I think it's rarely used and not recommended in most cases. If we try to create a new document, that will make HTML unorganizable with multiple DOM trees.
Even though in iframes, they have their own document objects
document.getElementById('frame-id').contentWindow.document
So I think we should not create a new one, if we can achieve our targets with the current document.
Related
I am building a project with Django 2.2.4 and PostgreSQL 11.4. I am using JSON database fields to store data in JSON arrays.
In my app users create documents using "rich text editor" that provides standard text/image features already.
I also want to enable users create the document to drag and drop form inputs into the body of the document so that once the document is "published" other users can view the document an add input values to these fields before submitting and saving the document again.
Now, I'm trying to figure out conceptually the most efficient way to approach this.
I thought the first step would be to use an abstracted rich text editor which separates the document structure from the HTML, e.g. CKEditor or Quill; if I was to serialise the document with form inputs included I could in theory store templates in one JSONField and inputs in another.
This list is a really useful overview of various editors, but despite having read a lot of documentation it's not clear if this approach would be either correct or actually possible.
Does anyone have any similar experiences?
Pretty sure this isn't possible unfortunately.
Could you elaborate on what you're trying to do with this?
I'm using roxygen2 to document the objects in my R package, as described in the book R packages. I want to insert some text at the top (and bottom) of the doc page for every object, saying for example, "Confidential - Do Not Release". For the HTML doc pages I could do that with a CSS content property, or by inserting some HTML of course.
So how can I modify the page headings of the doc pages rendered from roxygen2? For now I'm only interested in the HTML doc pages, not PDF, so it might be enough to insert some arbitrary CSS or HTML into every doc page with roxygen2, or Rd. Is that possible?
Ideally I'd like to find an option that I can set once globally for the whole package, since if I have to add it separately to each object's documentation, I may miss some. But if I have to add it to each object, I can live with it.
I'm in the process of exploring the possibilities of Word VSTO add-in. Using a combination of custom task pane(s), a custom ribbon and a series of dialog boxes or forms I can collection information from the user. However, what I can figure out is where I can persist this information within the document. A docx is made of a series of individual files, how do I add my file within the cab as well? Storing the custom info outside of the document is not an option, it must travel with the document itself.
Thanks,
Update : If I use custom xml parts per the solution mentioned here https://msdn.microsoft.com/en-us/library/bb608612.aspx then it appears to me that the xml data is visible to the user. See screen shot. The user should not be able to browse data that my add-in is storeing - not because it's senstitive but because it makes no sense for them to see and interact with a bunch of serialized class data.
You can store your custom information inside the document using so called Custom XML Parts. This information is stored within the document.
Here is an example how to add a Custom XML Part to your document:
How to: Add Custom XML Parts to Documents by Using VSTO Add-Ins
I have a requirement to display dynamically generated word document on the server in an html page
I tried using the OBJECT tag and the document was indeed displayed correct. But the toolbars like print, file etc are missing.
Note: secondary requirement is to enable the user to print the contents of the word document displayed, so the print toolbar is essential for this.
I'm not sure that this is actually possible. When you use the <object> tag, Word is being invoked to render the document, but you don't actually have a full-fledged instance of Word running in the browser. I doubt that there's any way to get Word to display its UI inside the <object> area.
You may have to write some javascript to invoke the browser's print capabilities.
I'm creating a cms and have not yet settled on the matter of where to store the complete url for a given page in the structure.
Every page have a slug (url friendly name of the page) and every page has a nullable (for top-level pages) parent and children.
Where do I store the complete url (/first-page/sub-page) for a given page? Should this go in the database along with the other properties of the page or in some cache?
Update
It's not the database design I'm asking about, rather where to store the complete url to a given page so I don't need to traverse the entire url to get the page that the user requested (/first-page/sub-page)
Update 2
I need to find which page belongs to the currently requested url. If the requested url is /first-page/sub-page I don't want to split the url and looping through the database (obviously).
I'd rather have the entire url in the table so that I can just do a single query (WHERE url = '/first-page/sub-page') but this does not seem ideal, what if I change the slug for the parent page? Then I also need to update the url-field for all descendants.
How do other people solve this issue? Are they putting it in the database? In a cache that maps /first-page-/sub-page to the id for the page? Or are they splitting the requested url and looping though the database?
Thanks
Anders
Store it in a cache, because the web servers will need to be looking up URLs constantly. Unless you expect the URLs of pages to change very rapidly, caching will greatly reduce load on the database, which is usually your bottleneck in database driven web sites.
Basically, you want a dictionary that maps URL -> whatever you need to render the page. Many web servers will automatically use the operating system's file system as the dictionary and will often have a built-in cache that can recognize when a file changes in the file system. This would probably be much more efficient than anything you can write in your CMS. It might be better, therefore, to have you CMS implement the structure directly in the file system and handle additional mapping with hard or soft links.
I just did this for MvcCms. I went with the idea of content categories/sub categories and content pages. When a content category / subcategory is created I go recursively through the parents and build the entire route and then store it in the category table. Then when the page is requested I can find the correct content page and find out when going through a nav structure if the current nav being built is the current or active route.
This approach requires some rules about what happens when a category is edited. The approach right now is that once the full path is set for a sub category it can't be change later with the normal tools.
The source is a mvccms.codeplex.com