Re: looking for examples -- link to insert the "content" into a given area

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The short answer is to put in a span tag in the location that you want the content to appear.
Give the span tag a UNIQUE id and use the DOM method getElementById( tag id )
then insert the content. In the simplest form as a string. 

<span id="spanID"></span>

// javascript source
let target = document.getElementById('spanID');
if(target.hasChildNodes())
 {
  target.childNodes[0].data = 'text to insert';
}
else
  {
   target.appendChild(document.createTextNode('text to insert'));
}

The above will insert a string as a child of the span tag

<span id="spanID">text to insert</span>

But this can get very complicated if you need to insert other elements

It is worth mentioning also, that the span tag should be a child of a pre
tag. trying to insert text in a p tag will not result in the expected behavior
of a p tag, in my experience. The span tag will inherit what ever the 
CSS rules are assigned to the pre tag. The pre tag is for pre formatted
strings as well as most other elements

<pre><span id='SPID'></span></pre>

This also assumes that you have enough experience with javascript to
know how to use this successfully.

> 
> On Mar 15, 2025, at 9:53 AM, bruce <badouglas@xxxxxxxxx> wrote:
> 
> Hi.
> 
> Combination php/js issue.
> 
> Trying to find example/explanation on how to insert content froma link into a given area.  Just as a test, did a test webapp, and tested
>   http://1.2.3.4:/aa.html and the entire page was displayed from exa,img the page source. . So, I was curious as yo the process if I had a menu item, that returned content, if I wanted to insert that content into an area on a page. How to accomplish this.
> 
> Searching, haven't found an explanation yet.
> 
> thanks
> 




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux