HTML DOM Input URL name Property

HTMLWeb DevelopmentFront End Technology

<p>The HTML DOM Input URL name property returns a string, which is the value of the name property of input URL. User can also set it to a new string.</p><h2>Syntax</h2><p>Following is the syntax &minus;</p><ul class="list"><li>Returning string value</li></ul><pre class="result notranslate">inputURLObject.name</pre><ul class="list"><li>Setting <strong>name&nbsp;</strong>attribute to a string value</li></ul><pre class="result notranslate">inputURLObject.name = &lsquo;String&rsquo;</pre><h2>Example</h2><p>Let us see an example of <strong>Input URL name</strong> property &minus;</p><p><a class="demo" href="http://tpcg.io/WoR7nU" rel="nofollow" target="_blank">&nbsp;Live Demo</a></p><pre class="prettyprint notranslate">&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Input URL name&lt;/title&gt; &lt;style&gt; &nbsp; &nbsp;form { &nbsp; &nbsp; &nbsp; width:70%; &nbsp; &nbsp; &nbsp; margin: 0 auto; &nbsp; &nbsp; &nbsp; text-align: center; &nbsp; &nbsp;} &nbsp; &nbsp;* { &nbsp; &nbsp; &nbsp; padding: 2px; &nbsp; &nbsp; &nbsp; margin:5px; &nbsp; &nbsp;} &nbsp; &nbsp;input[type=&quot;button&quot;] { &nbsp; &nbsp; &nbsp; border-radius: 10px; &nbsp; &nbsp;} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;form&gt; &lt;fieldset&gt; &lt;legend&gt;URL-name&lt;/legend&gt; &lt;label for=&quot;URLSelect&quot;&gt;Employee URL: &lt;input type=&quot;url&quot; id=&quot;URLSelect&quot; value=&quot;https://www.example.com&quot; name=&quot;Jack&quot;&gt; &lt;/label&gt; &lt;input type=&quot;button&quot; onclick=&quot;getName()&quot; value=&quot;Who is the Owner? &quot;&gt; &lt;div id=&quot;divDisplay&quot;&gt;&lt;/div&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;script&gt; &nbsp; &nbsp;var divDisplay = document.getElementById(&quot;divDisplay&quot;); &nbsp; &nbsp;var inputURL = document.getElementById(&quot;URLSelect&quot;); &nbsp; &nbsp;function getName() { &nbsp; &nbsp; &nbsp; if(inputURL.value === &#39;https://www.example.com&#39;) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;divDisplay.textContent = &#39;Above URL belongs to &#39;+inputURL.name; &nbsp; &nbsp; &nbsp; else &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;divDisplay.textContent = &#39;Above URL belongs to no one!&#39;; &nbsp; &nbsp;} &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;</pre><h2>Output</h2><p>This will produce the following output &minus;</p><p>Before clicking <strong>&lsquo;Who is the Owner?&rsquo;</strong> button &minus;</p><p><img src="https://www.tutorialspoint.com/assets/questions/media/25780/url_name.jpg" class="fr-fic fr-dib" style="width:600px; height:215px;" width="600" height="215"></p><p>After clicking <strong>&lsquo;Who is the Owner?&rsquo;</strong> button &minus;</p><p><img src="https://www.tutorialspoint.com/assets/questions/media/25780/after_url_name.jpg" class="fr-fic fr-dib" style="width:600px; height:219px;" width="600" height="219"></p>
raja
Updated on 30-Jul-2019 22:30:26

Advertisements