Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Thursday, April 22, 2021

HTML dialog Tag


dialog.html:

<html>

<body>

<button onclick="openDialog()">Open Dialog</button>

<dialog id="myDialog"><iframe src="dialogbox.html"></iframe></dialog>

<script>

function openDialog() {

  document.getElementById("myDialog").showModal();

}

</script>

</body>

</html>


dialogbox.html:

<html>

<body>

<button onclick="parent.document.getElementById('myDialog').close()">

Click to close

</button>

</body>

</html>

 

Thursday, March 21, 2019

HTML: style and class


HTML inline styles can be replaced by using CSS class. For example, the following code:

<p id="p1" style="font-size:100px; color:blue;">Big blue</p>

can be rewritten into

<p id="p2" class="bigblue">Big blue</p>

by using a "bigblue" class defined in a linked CSS file:

.bigblue {
  font-size:100px;
  color:blue;
}


There is something we need to pay attention to if we want to dynamically hide and show an element with the style.display property. For example, if we want to hide the above "p1" element initially and later show it, we can do this with inline style:

<p id="p1" style="font-size:100px; color:blue; display:none;">Big blue</p>

<script type="text/javascript">
  // Later, we remove the style.display property to show the element.
  document.getElementById("p1").style.display = "";
</script>


However, for the other approach with CSS class, resetting style.display doesn't work:

.bigblue {
  font-size:100px;
  color:blue;
  display:none;
}


<p id="p2" class="bigblue">Big blue</p>

<script type="text/javascript">
  document.getElementById("p2").style.display = "";   // "p2" won't show up
</script>


We would need to explicitly set the style.display to its default value "inline" to make the element show up:

<script type="text/javascript">
  document.getElementById("p2").style.display = "inline";  

</script>

Thursday, March 14, 2019

View Source of different browsers


Sometime you are not able to use the View Source function from the context menu of the browser. Some web pages may purposely disable the context menu.

Through the browser's Developer Tools, you will be able to "View Source" for any pages.

Similar Developer Tools are available in the major browsers:
  • Goolge Chrome: Click on the Vertical Ellipsis icon and select More tools/Developer tools
  • Firefox: Click on the Open Menu icon and select Web Developer
  • IE: Click on the Gear icon and select F12 Developer Tools
After the Developer Tools are opened, select the Network tab. You may need to click on the Record icon if there is one.

Reload the web page.

You will see the requests being sent to the server. Find the one whose URL is that you are looking for and click on it to see the details.

Select the Response (or Response Body) tab in the details. The source code of the web page is there.

 
Get This <