from browser import document
from browser.html import OBJECT
def load_link_href(e):
e.preventDefault()
if section.childElementCount == 1:
document['section_obj'].remove()
if e.target.href.endswith('.pdf'):
section <= OBJECT(data=e.target.href, type='application/pdf', id='section_obj')
elif e.target.href.endswith('.html'):
section <= OBJECT(data=e.target.href, type='text/html', id='section_obj')
for link in links:
link.style.backgroundColor = '#8F00FF'
e.target.style.backgroundColor = 'rgb(111, 50, 168)'
section = document['section']
links = document.getElementsByClassName('link')
for link in links:
#link.style.width = str(100/len(links)) + '%'
link.bind('click', load_link_href)
links[0].click()